You need to sign in to do that
Don't have an account?
David Berman
How to parse badly-formed JSON
If I had JSON that looked like this:
{ "user" : { "name" : "Simon Fell", "twitter" : "@superfell" } }, then I would set up a User class with the name and twitter properties.
In my case my JSON looks like this:
The problem I'm facing is that the id (e.g. 5599357, 5752807) is repeated infront of the key/value pairs that follows.
Could someone suggest how I could parse out the information into a User class/object with attributes full_name, photo_path, email_address, headline, account_id and id?
By the way this is JSON returned from Mavenlink.
Thanks!
{ "user" : { "name" : "Simon Fell", "twitter" : "@superfell" } }, then I would set up a User class with the name and twitter properties.
In my case my JSON looks like this:
{"count":2,"users": {"5599357":{"full_name":"Accounting","photo_path":"https://....s3.amazonaws.com/attachments/final/2015-06-09/5599357/2928b4_default","email_address":"accounting@acme.com","headline":"","account_id":"3473215","id":"5599357"}, "5752807":{"full_name":"JDoe","photo_path":"https://.../default.png","email_address":"jdoe@acme.com","headline":null,"account_id":"3783877","id":"5752807"}}}
The problem I'm facing is that the id (e.g. 5599357, 5752807) is repeated infront of the key/value pairs that follows.
Could someone suggest how I could parse out the information into a User class/object with attributes full_name, photo_path, email_address, headline, account_id and id?
By the way this is JSON returned from Mavenlink.
Thanks!
1: Use explicit parsing. Json2apex.herokuapp.com can help generate that code.
2: using Text manipulation methods to massage the incoming json string before parsing it.
I tried option 1, but it would just create a separate class for each id (e.g. 5599357, 5752807, both with the same full_name, id, etc. attributes), so that's not viable solution... unless there's a programmatic way whereby a scheduled Apex job could call that heroku app and somehow return all those numberic classes?
Can you help me with option 2, given the above example? I'm a bit at a loss as to where to start. Thanks..