You need to sign in to do that
Don't have an account?
hsupriya
Parsing JSON. Urgent help!
My JSON output looks as follows:
{\n \"Name\" : \"mary mercy\",
\n \"Email\":\"mmercy@gmail.com\",
\n \"Phone\" :\"(xxx) xxx-xxx\"\n}"
I want to be able to be parse these individual values Name, Email and Phone and display them on the VF page.
I tried using deserialize, but it gave me the fatal error saying,
Malformed JSON: Expected '[' at the beginning of List/Set
Please help. Thanks
Hello VBS,
You are right. The issue was with the way JSON was being received.
So, in my class(Databse.com), from where I was sending JSON to salesforce, I returned the Salesforce object instead of returning the JSON string and tha resolved my issue.
Thanks anyway!
All Answers
I find http://jsonlint.com/ incredibly useful for trying to tweak JSON. It looks like it has something to do with your escapes, as:
Validates fine. What's the situation that you need to try and escape this out?
Hello Josh,
Thanks for the reply.
So, I have integrated Databse.com and Salesforce.com and this is the response I am getting from Databse.com. I need to separate all the fields from JSON into separate strings and display them on the associated VF page.
So you are calling a DB.com REST API via a Visualforce page on Salesforce?
yes, something similar.
JSON parsing has been a nightmare for me always. The site you mentioned is quite useful. If at all I could get rid of new line and escape characters from the response, I will manage to get the valid JSON.
But was wondering, if there is any workaround. May be I should serialize the JSON at Database.com itself and then send to salesforce?
Hello VBS,
You are right. The issue was with the way JSON was being received.
So, in my class(Databse.com), from where I was sending JSON to salesforce, I returned the Salesforce object instead of returning the JSON string and tha resolved my issue.
Thanks anyway!