A lot of JSON parsing frameworks have the option of pretty printing.
For instance SBJsonWriter
. It has a humanReadable
property.
If set to YES, generates human-readable JSON with linebreaks after each array value and dictionary key/value pair, indented two spaces per nesting level.
If you just want the indentation logic you can dig in and just use that part and strip your project of unnecessary SBJson files.
EDIT:
From OS X 10.7, NSJSONSerialization
is available natively in Cocoa.
You can pass the NSJSONWritingPrettyPrinted
as an option to
+dataWithJSONObject:options:error:
class method of NSJSONSerialization
to achieve what you want.