JSON vs OCON (Objective-C Object Notation)
I’m here to propose another alternative to JSON, Messagepack, Protobuf, and all those other data-transfer formats which are, frankly, about to be made redundant by the introduction of a elegant, concise, and eminently readable format called OSON: Objective-C Object Notation (pronouced O-son).
Here’s an example piece of JSON from their website, quite an ugly piece of work isn’t it?
{"menu": {
"id": "file",
"value": "File",
"popup": {
"menuitem": [
{"value": "New", "onclick": "CreateNewDoc()"},
{"value": "Open", "onclick": "OpenDoc()"},
{"value": "Close", "onclick": "CloseDoc()"}
]
}
}}Now, let me fix that for you:
[NSDictionary dictionaryWithObjectsAndKeys:
[NSDictionary dictionaryWithObjectsAndKeys:
@"file", @"id",
@"File", @"value",
[NSDictionary dictionaryWithObjectsAndKeys:
[NSArray arrayWithObjects:
[NSDictionary dictionaryWithObjectsAndKeys:
@"New", @"value",
@"CreateNewDoc()", @"onclick", nil],
[NSDictionary dictionaryWithObjectsAndKeys:
@"Open", @"value",
@"OpenDoc()", @"onclick", nil],
[NSDictionary dictionaryWithObjectsAndKeys:
@"Close", @"value",
@"CloseDoc()", @"onclick", nil],
nil],
@"menuitem", nil],
@"popup", nil],
@"menu", nil];Much better! ;)