Considering the formats you emit: If you want to make the life of your consumers as easy as possible, consider also emitting your data in .plist format – if you are creating the API for consumption by mobile devices, likely some iphones will be among them and iOS has really specialized (=fast) APIs for dealing with plists.

You can use the Accept-header for clients to tell the server what output they prefer (JSON or plist).

Then, just deal with your data internally and serialize either as JSON or as plist (https://github.com/rodneyrehm/CFPropertyList) as the very last step