Serialize data so it's JSON safe