DISQUS

DISQUS Hello! toxicsoftware.com is using DISQUS, a powerful comment system, to manage its comments. Learn more.

Community Page

Jump to original thread »
Author

CocoaJSON

Started by schwa · 10 months ago

Blake Seely released some code yesterday to convert Cocoa datatypes to JSON. I’ve had similar code that I’ve been meaning to put online for a while now. So now the world has gone from zero to two Cocoa code-bases to read/write JSON.

The code is in subversion here, an ... Continue reading »

10 comments

  • You can never have too much code :) I have to credit Buzz for the idea, though - and he mentioned that he got some code started, too. Can't wait to check yours out - I'm definitely curious to see how others are handling a few things I had questions about!
  • I've been looking at using JSON as well but it appears some data just isn't represented well with Cocoa data structures such as multidimensional arrays.. I'm using QuickLite to get an NSArray of values for each dimension and then simply enumerating through the array to get each integer value and outputting it to a space delimited text file which is uploaded to the server. Javascript on the server then reads the values from the text file to create the multidimensional array.. There has to be a cleaner way then what I am doing.
  • Not sure what you mean about JSON not handling multidimensional arrays? Did a few quick tests, and both the CocoaJSON code, and my own code outputs it just fine - but maybe you're question isn't whether it can handle multidimensional arrays, but whether it's easy?
  • Yes.. I know JSON handles it fine.. but making multidimensional arrays in Cocoa using NSArray's is very convoluted when looking at the code to create one... Perhaps I'm being too picky :)
  • Well feel free to create your own multiple array object in Objective-C then just provide a serialiser/deserialiser methods for them. Not sure if I made my code extensible in this way - but should be easy to add in.
  • Maybe I'm being incredibly stupid, but these classes seem to choke on whitespace. The code isn't capable of parsing something simple like:

    {
    "firstName": "Jim",
    "lastName": "Morrison"
    }

    I thought the culprit might be NSScanner_Extensions skipWhitespace. Surely this should be using whitespaceAndNewlineCharacterSet instead of whitespaceCharacterSet?

    So, I tried changing it. This got the scanner a couple of characters further but it still bails out at the first opportunity. I had a look at the unit tests to see whether they would prove my suspicions wrong. They only served to confirm them, though: all unit tests test against single-line input.

    Am I expecting too much? Am I missing something?
  • Hey Mr Mojo,

    It _should_ work, so you could be doing something braindead. Or it could just be buggy. I'm not doing any work on CocoaJSON right now so feel free to fix it and send me a patch :-)

    Otherwise I'll add to the list of things I need to do. I really need a public facing bug tracker.

    Cheers.

    Jon.
  • Under what license are you publishing this? I see no mention of a license in any of your files.

    Thanks!
  • Neither the link to the zip or the link work anymore. Is this still available?
  • See /subversion-moved/

Add New Comment

Returning? Login