serialize nested JSON objects