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
Tanvi KakkarTanvi Kakkar 

Deserialize json and show in Visual page

I have a json file : 
{"@odata.context":")","value":[{"id":"DA5019C32CA4C20F!107","name":"770-small.jpg","webUrl":""},{"id":"DA5019C32CA4C20F!108","name":"images.png","webUrl":""},{"id":"DA5019C32CA4C20F!109","name":"Salesforce_com_thumb230.png","webUrl":""}]}

I need to show this JSON file in VF table .
Need to get the id name and web url in three cloumn in table. 

Please Help . Thanks in advance . 


 
Vivek_PatelVivek_Patel
Hi Tanvi,

I has stored the JSON in the description field on the contact and following code works for you scenario.
read the value in the object structure to display on the page, there are other ways also to do this, but I think if you want to use the apex and visualforce, this is the right approach.
 
public class MyObject {	    
	public List<ValueWrapper> value;
}
public class ValueWrapper {
	public String id;
	public String name;
	public String webURL;
}

String jsonString = [SELECT Id, Description FROM Account WHERE Id='0019000001BHTOD'][0].description;
MyObject obj = (MyObject)JSON.deserialize(jsonString, MyObject.class);
System.debug(obj.value[0].id);
System.debug(obj.value[0].name);
System.debug(obj.value[0].webURL);

Let me know if this helps