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?
<code> "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"
}
]
}
</code>
<code> "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"
}
]
}
</code>
"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:
<code>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; }
}
</code>
<code>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; }
}
</code>
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; }
}