Rohit Bajaj
asked on
Convert from a json string array to a Java object
HI,
I am getting the following json object which consists of an array inside from a api call in response :
I am interested in elements inside the refs tag which has totalcount, edges and pageInfo
The pageInfo element is fine but the edges node has a weird structure... All i am interested in is the data that it has...
the name directly inside the node tag is branchname..
The data i am interested in from each node is branchname, name, date, login
So i would like this json to be converted into a array of java object where each object would store the above bolded tags direclty..
I dont want to make an edge, node, typename class etc.. that would seem very weird.
The pageInfo and totalCount can be fetched separately..
How do i do it in java .
Thanks
I am getting the following json object which consists of an array inside from a api call in response :
{
"data": {
"repository": {
"refs": {
"totalCount": 13,
"edges": [
{
"node": {
"name": "autefixer",
"target": {
"__typename": "Commit",
"author": {
"name": "salman",
"date": "2017-01-19T13:12:04+05:30",
"user": {
"login": "salman"
}
}
}
}
},
{
"node": {
"name": "chre",
"target": {
"__typename": "Commit",
"author": {
"name": "salman",
"date": "2017-02-07T12:32:38+05:30",
"user": {
"login": "salman"
}
}
}
}
},
{
"node": {
"name": "ck6",
"target": {
"__typename": "Commit",
"author": {
"name": "salman",
"date": "2017-01-23T12:42:01+05:30",
"user": {
"login": "salman"
}
}
}
}
},
{
"node": {
"name": "ckePgin",
"target": {
"__typename": "Commit",
"author": {
"name": "salman",
"date": "2017-02-07T17:57:25+05:30",
"user": {
"login": "salman"
}
}
}
}
},
{
"node": {
"name": "localon",
"target": {
"__typename": "Commit",
"author": {
"name": "rohit",
"date": "2017-01-10T12:29:25+05:30",
"user": null
}
}
}
},
{
"node": {
"name": "markdme",
"target": {
"__typename": "Commit",
"author": {
"name": "rohit",
"date": "2017-01-02T18:20:12+05:30",
"user": null
}
}
}
},
{
"node": {
"name": "marwn",
"target": {
"__typename": "Commit",
"author": {
"name": "rohit",
"date": "2016-08-10T16:26:10+05:30",
"user": null
}
}
}
},
{
"node": {
"name": "maer",
"target": {
"__typename": "Commit",
"author": {
"name": "salman",
"date": "2017-02-08T17:59:47+05:30",
"user": {
"login": "salman"
}
}
}
}
},
{
"node": {
"name": "notesSle",
"target": {
"__typename": "Commit",
"author": {
"name": "salman",
"date": "2017-02-08T19:28:34+05:30",
"user": {
"login": "salman"
}
}
}
}
},
{
"node": {
"name": "reftor",
"target": {
"__typename": "Commit",
"author": {
"name": "salman",
"date": "2017-02-02T14:24:56+05:30",
"user": {
"login": "salman"
}
}
}
}
}
],
"pageInfo": {
"endCursor": "MTA=",
"hasNextPage": true
}
}
}
}
}
I am interested in elements inside the refs tag which has totalcount, edges and pageInfo
The pageInfo element is fine but the edges node has a weird structure... All i am interested in is the data that it has...
the name directly inside the node tag is branchname..
The data i am interested in from each node is branchname, name, date, login
So i would like this json to be converted into a array of java object where each object would store the above bolded tags direclty..
I dont want to make an edge, node, typename class etc.. that would seem very weird.
The pageInfo and totalCount can be fetched separately..
How do i do it in java .
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
http://www.jsonschema2pojo.org/ is interesting but doesn't work with the given json