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],
            @"menuitem", nil],
        @"popup", nil],
    @"menu", nil];

Much better! ;)

Thanks for reading! And if you want to get in touch, I'd love to hear from you: chris.hulbert at gmail.

Chris Hulbert

(Comp Sci, Hons - UTS)

iOS Developer in Sydney.

I have worked at places such as Google, Cochlear, News Corp, Fox Sports, NineMSN, FetchTV, Woolworths, and Westpac, among others. If you're looking for a good iOS developer, drop me a line!

Get in touch:
[email protected]
my resume

 Subscribe via RSS