You need to sign in to do that
Don't have an account?
Ritesh001
how to convert soql result to Json format using wrapper class
Need Urgent Help in converting the soql result to get as per the below json format as shown in image.
List<Custom_Shipping__mdt> = [selelct Country__c,State__c,Countrycode__c,Sattecode__c from Custom_Shipping__mdt];
example soql result-
Coutry - India , Country code - 34 , State - MH,Delhi State code - 44 ,45
Country Code & Satte Code -
34-44 , 34-45
This query is giving me all the data from custom metadata
Need to Convert the country & state with their code in below Json format using wrapper & pass to lightining component.
List<Custom_Shipping__mdt> = [selelct Country__c,State__c,Countrycode__c,Sattecode__c from Custom_Shipping__mdt];
example soql result-
Coutry - India , Country code - 34 , State - MH,Delhi State code - 44 ,45
Country Code & Satte Code -
34-44 , 34-45
This query is giving me all the data from custom metadata
Need to Convert the country & state with their code in below Json format using wrapper & pass to lightining component.
Try creating a wrapper class with two attributes: Then create AuraEnabled method to create a map as requested:
You cannot create the Javascript functions directly in Apex. Instead you need to add getProvinceOptions and getCountryOptions in Lightning controller.
Regards,
Mkr
You need to read about the JSON class of Salesforce through this you can create the desire JSON.
Here is the link of JSON Class:
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_class_System_Json.htm
https://salesforce.stackexchange.com/questions/126212/how-to-convert-list-data-into-json-in-apex
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks,
Ajay Dubedi