• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Converting JSON to equivalent Foundation objects
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Converting JSON to equivalent Foundation objects


  • Subject: Converting JSON to equivalent Foundation objects
  • From: Paul Stringer <email@hidden>
  • Date: Tue, 09 Dec 2008 10:01:17 +0000

I'm connecting to a webservice and getting JSON back, creating a JSONObject/JSONArray which I then want back as it's foundation equivalent of say NSDictionary.

I'm sure this has been done already and I'm looking at Wonders NSArraySerializer and NSDictionarySerializer but I think I'm missing some knowledge about these things, I need to register them with a Bridge or something perhaps?

Using tryUnmarshall I get an error of "source object must be already registered as a ProcessedObject" with the following probably very wrong code:

String s = jsonStringFromWebService();
JSONObject results = new JSONObject(s);
JSONObject jo = new JSONObject();
jo.put("javaClass", NSArray.class.getCanonicalName());
jo.put("nsarray", results.get("results"));
NSArraySerializer nas = new NSArraySerializer();
SerializerState ss = new SerializerState();
try {
	ObjectMatch m = nas.tryUnmarshall(ss, NSArray.class , jo);
	log.info(m);
} catch (UnmarshallException e) {
	// TODO Auto-generated catch block
	e.printStackTrace();
}

Thanks

Paul S
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Converting JSON to equivalent Foundation objects
      • From: Andrew Lindesay <email@hidden>
  • Prev by Date: Re: Custom Type for NSTimestamp
  • Next by Date: Re: Custom Type for NSTimestamp
  • Previous by thread: Re: Question about UI technique for adding a new object to a list
  • Next by thread: Re: Converting JSON to equivalent Foundation objects
  • Index(es):
    • Date
    • Thread