serialize data object to json before sending to app