function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
mrizmriz 

How to Pass values (List/Map) from Apex to JavaScript/Jquery

I have a requirement wherein i want to pass values from Apex to Javascript/jQuery. I want to add some properties to the values received in jQuery and then add those values on VF page.

(I want to create hierarchy of a custom object record which can be related to different objects and the level of depth and width is n).
Abhilash Mishra 13Abhilash Mishra 13
I am not sure about List/map and i Dont think its gonna work. why dont you use JSON instead. its perfect for such requirements.
mrizmriz
@abhilash, can you please shed more light on handling JSON data in apex?
Abhilash Mishra 13Abhilash Mishra 13
 Hi mritzi,
You can Learn from here.
https://developer.salesforce.com/page/Getting_Started_with_Apex_JSON
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_class_System_Json.htm
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_class_System_JsonGenerator.htm


regarding JSON Hadling You can learn from above links. If you want to create a  hierarchy  you can gererate a json  like
[
{ "name":"abilash" , "nickname" :"mishra", "childrens":
 [
    { "name":"child1" }
 ]

}]

transfer this to javascript and all set.

Let me Know if you are lacking 
Happy to help.
Please upvote if this helps.