Actually, I feel like a dunce, this fails because I was running on Snow Leopard. NSJSONSerialization isn't supported until 10.7.
I'll leave this question up for anyone else who stubbles across the same thing.
Question
How can I get NSJSONSerialization to be recognized in macruby?
framework 'foundation'
puts NSXMLDocument
#=> NSXMLDocument
puts NSJSONSerialization
#=> /Users/home/Desktop/Dropbox/script.rb:3:in `<main>':
uninitialized constant NSJSONSerialization (NameError)
also
$ macruby -v
MacRuby 0.12 (ruby 1.9.2) [universal-darwin10.0, x86_64]
Solution
Actually, I feel like a dunce, this fails because I was running on Snow Leopard. NSJSONSerialization isn't supported until 10.7.
I'll leave this question up for anyone else who stubbles across the same thing.
OTHER TIPS
irb(main):001:0> framework 'foundation'
=> true
irb(main):002:0> puts NSJSONSerialization
NSJSONSerialization
=> nil
irb(main):014:0> NSJSONSerialization.dataWithJSONObject(['dog', 'cat', 'rabbit'], options:0, error:nil).to_str
=> "[\"dog\",\"cat\",\"rabbit\"]"
$ macruby -v
MacRuby 0.13 (ruby 1.9.2) [universal-darwin10.0, x86_64]
Maybe it's fixed in later builds. This actually is not specific to RubyMotion, but NSJSONSerialization
is something of broad enough interest it's worth keeping the question tagged as such.