0

I have a string with JSON notation in VF page and I want to iterate over it and create a table. I am trying to display in table but has not got anywhere. I am looking for some suggestion to achieve this.

This is the String:

{"label":[{"Id":"0017F00000Pf3NpQAJ","Name":"Edge Communications,{"Id":"0017F00000Pf3NqQAJ","Name":"Burlington Textiles Corp of America"},{"Id":"0017F00000Pf3NrQAJ","Name":"Pyramid Construction Inc."},{"Id":"0017F00000Pf3NwQAJ","Name":"University of Arizona"},{"Id":"0017F00000Pf3NxQAJ","Name":"United Oil & Gas, UK"},{"Id":"0017F00000Pf3NsQAJ","Name":"Dickenson plc"},{"Id":"0017F00000Pf3NtQAJ","Name":"Grand Hotels & Resorts Ltd"},{"Id":"0017F00000Pf3NyQAJ","Name":"United Oil & Gas, Singapore"},{"Id":"0017F00000Pf3NzQAJ","Name":"GenePoint"},{"Id":"0017F00000Pf3O0QAJ","Name":"sForce"},{"Id":"0017F00000Pf3NuQAJ","Name":"United Oil & Gas Corp."},{"Id":"0017F00000Pf3NvQAJ","Name":"Express Logistics and Transport"}]}

  • Create an apex class using json2apex (json2apex.herokuapp.com) and then store values to json to that object's attribute and finally display those in VFP – Santanu Boral Jul 25 '18 at 12:51
  • I have tried this but I am receiving this error: sorry, unable to parse your json: Unexpected character ('I' (code 73)): was expecting comma to separate OBJECT entries at [Source: java.io.StringReader@43d33e1b; line: 1, column: 68] – devforce Jul 25 '18 at 12:57
0

Create an apex class as follows using JSON2Apex

public class JSON2Apex {

    public List<Label> label;

    public class Label {
        public String id;
        public String Name;
    }


    public static JSON2Apex parse(String json) {
        return (JSON2Apex) System.JSON.deserialize(json, JSON2Apex.class);
    }
}

Then, create a visualforce page and controller class to display those values in VFP.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.