You need to sign in to do that
Don't have an account?
Shubham Sinha 56
how to use JSON output
Hello,
I have one scenarion where I am getting output in JSON format .
JSON - {"SystemModstamp":{"oldValue":"2021-06-10T08:32:25.000Z","value":"2021-06-10T09:03:24.000Z"},"Status":{"oldValue":"New","value":"Accept"}}
I want to use this output in IF condition in my JS of lightning component. Like if Status Value is' Accept' then do my logic.
P.S. SystemModstamp, Status both are fields of Lead.
Please help me on this. Thanks in advance
I have one scenarion where I am getting output in JSON format .
JSON - {"SystemModstamp":{"oldValue":"2021-06-10T08:32:25.000Z","value":"2021-06-10T09:03:24.000Z"},"Status":{"oldValue":"New","value":"Accept"}}
I want to use this output in IF condition in my JS of lightning component. Like if Status Value is' Accept' then do my logic.
P.S. SystemModstamp, Status both are fields of Lead.
Please help me on this. Thanks in advance
You could use Apex code like below to get the parsed values from json and then use it accordingly by storing in some variable, Here is sample code for your understanding: Also, we have JSON to Apex application(https://json2apex.herokuapp.com/) where the response can be converted to get the relevant apex and then you can process the response according to the standard documentation as mentioned in below links:
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_json_jsonparser.htm
Some more helpful links:
https://intellipaat.com/community/19062/multi-level-nested-json-parsing-with-apex-salesforce
https://developer.salesforce.com/forums/?id=9060G000000I17RQAS
Hope above information helps. Please mark as Best Answer so that it can help others in future.
Thanks.
I don't know you are using the LWC or Aura.
But you can try like below :
You no need to declare JSON string for testing purpose i have created
Thanks,
Maharajan.C
Greetings!
There are two ways to handle this JSON.
First, create a wrapper class with these variables to directly deserialize JSON using your wrapper class.
Second, Please use deserializeUntyped to break this JSON into Map where the key is String and Value is Object.
If you find your Solution then mark this as the best answer.
Thank you!
Regards,
Suraj Tripathi