Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 12111

How to parse complex JSON in Java?

$
0
0

I am very new to API calls and handling JSON response.I have the below complex JSON response in Java. This needs to be parsed so that I can save all the 'url' in a String List. How can it be done?

{"totalSize": 3,"done": true,"records": [    {"attributes": {"type": "Account","url": "/services/data/v60.0/sobjects/Account/0015i00000fi1GUAAY"      },"Id": "0015i00000fi1GUAAY"    },    {"attributes": {"type": "Account","url": "/services/data/v60.0/sobjects/Account/0015i00000fi1GgAAI"      },"Id": "0015i00000fi1GgAAI"    },    {"attributes": {"type": "Account","url": "/services/data/v60.0/sobjects/Account/0015i00000fi1GdAAI"      },"Id": "0015i00000fi1GdAAI"    }    ]} 

I have made the below pojo classes as well:

public class Record {    private Attributes attributes;    private String id;    public Attributes getAttributes() { return attributes; }    public void setAttributes(Attributes value) { this.attributes = value; }    public String getID() { return id; }    public void setID(String value) { this.id = value; }}public class Attributes {    private String type;    private String url;    public String getType() { return type; }    public void setType(String value) { this.type = value; }    public String getURL() { return url; }    public void setURL(String value) { this.url = value; }}

Viewing all articles
Browse latest Browse all 12111

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>