You need to sign in to do that
Don't have an account?

Getting Null value in JSON
Hi All,
I am working JSON Parsing which is very new to me. I am getting the response and deserialized by using below method.
I would like to get a list of Sub_Customers by using below method which is getting NULL Values.
Once I get the list<Object> I need to pass to Lightning: Datatable to display as a tree Grid view.
Regards,
VSK98
I am working JSON Parsing which is very new to me. I am getting the response and deserialized by using below method.
Map<String, Object> deSer = (Map<String, Object>) JSON.deserializeUntyped(resp.getbody());Response Body is below:
{ value = ({ group_name = *******, groupid = 1, sub_customer = [{ "CustomerId": "9488490", "CustomerName": "*******", "Street": "*******," City ":" KINGSWOOD "," PostalCode ":" ******* "," Country ": Australia", "Assetcnt": "0" }, { "CustomerId": "9488491", "CustomerName": "*******", "Street": "*******," City ":" PENRITH "," PostalCode ":" ******* "," Country ": Australia", "Assetcnt": "0" }, { "CustomerId": "94106344", "CustomerName": "*******", "Street": "*******," City ":" KINGSWOOD "," PostalCode ":" ******* "," Country ": Australia", "Assetcnt": "0" }, { "CustomerId": "94126502", "CustomerName": "*******", "Street": "DERBY STREET," City ":" KINGSWOOD "," PostalCode ":" ******* "," Country ": Australia", "Assetcnt": "0" }, { "CustomerId": "94106486", "CustomerName": "*******", "Street": "*******," City ":" KINGSWOOD "," PostalCode ":" ******* "," Country ": Australia", "Assetcnt": "0" }, { "CustomerId": "9488489", "CustomerName": "*******", "Street": "*******," City ":" PENRITH "," PostalCode ":" ******* "," Country ": Australia", "Assetcnt": "0" }] }) }
I would like to get a list of Sub_Customers by using below method which is getting NULL Values.
List<Object> lstObj = (List<Object>) deSer.get('sub_customer');
Once I get the list<Object> I need to pass to Lightning: Datatable to display as a tree Grid view.
Regards,
VSK98
Mean first get the value
and convert it to map
from there get thr sub_customer
I request you to validate the format of JSON DATA. i think you have formed the format wrongly.
copy your JSON data and paste here then click validate, if your corretc structure of JSON Data. its easy to get the value using this code.
as per my understanding your JSON data FOrmat is wrong. For Example
"Street": "*******,"
City ":" KINGSWOOD ",
" PostalCode ":" ******* ",
" Country ": Australia",
"Assetcnt": "0"
"Street": "*******,"-- See the comma where its placed its after double qts.
value = ({ group_name = *******, groupid = 1, sub_customer =
Use : insted of = values should be in side qts.
use this URL.
https://codebeautify.org/jsonviewer
Hope this will give you some idea.
Thanks
karthik
Please find the response below. I hope response is valid .
Regards,
VSK98
Good work.
kinldy use the below code to get the values of sub_customer.
Hope this will help to get those value.
Thanks
karthik
I had tried the same method but I am getting NULL values...
Regards,
VSK98
Can you post your apex class or your full code to try it from my side.
Thaks
karthik
Thanks for the quick response !!
Apex Class:
Regards,
VSK98
Try this code,
Thanks
karthik