I have a structure of simple container classes like so (in pseudo ruby):
class A
attr_reader :string_field1, :string_field2
...
end
class B
attr_reade
I had the same problem (mainly trying to create JSON strings of arbitrary complexity) rather than parsing them. After looking all over for a non-invasive class that will take a Ruby object (including nested arrays) and marshal it as a JSON string I finally wrote my own simple serialiser. This code also escapes special characters to create valid JSON.
http://www.keepingmyhandin.com/Downhome/Sketchup/simplejsonserializerrubyimplementation
All you have to do is:
json = JSON.new;
jsonString = json.marshal(obj); # Where obj is a Ruby object