Serialize objects and subarrays as JSON