I have the following valid JSON (I tested on jsonlint.com):
{
"Structure": {
"paper": "Paper",
"solid_reviewer": "Solid Reviewer",
"second_reviewer": "2. Reviewer",
"third_reviewer": "3. Reviewer"
},
"ReviewerGroup": {
"3457": {
"paper": "3457",
"solid_reviewer": {
"druidkey": "168",
"match": "Interest match"
},
"second_reviewer": {
"druidkey": "192",
"match": "Interest match"
},
"third_reviewer": {
"druidkey": "155",
"match": "Interest match"
}
},
"3458": {
"paper": "3458",
"solid_reviewer": {
"druidkey": "229",
"match": "Interest match"
},
"second_reviewer": {
"druidkey": "145",
"match": "Interest match"
},
"third_reviewer": {
"druidkey": "123",
"match": "Interest match"
}
},
"275": {
"paper": "275",
"solid_reviewer": {
"druidkey": "999",
"match": "Interest match"
},
"second_reviewer": {
"druidkey": "412",
"match": "Interest match"
},
"third_reviewer": {
"druidkey": "713",
"match": "Interest match"
}
}
},
"failedPapers": {}
}
In PHP, to decode this i simply do:
$response = json_decode($response);
and i can iterate through the $response object:
foreach ($response->ReviewerGroup as $r){
$paperRev1 = $paperReviewDAO->find(**$r->paper**, 1);
$revConf = $revConfDAO->findRevConfFromReviewer($confId,
**$r->solid_reviewer->druidkey**);
.
.
}
But it seems to be a lot more complicated in Java.
I have seen a lot of examples on how to read one object or an array of objects.
But how do i get all 'ReviewerGroup' (RG) objects and iterate through them? I need to extract the information from each of them and insert the data into a database (i know how to do that...) as an entity for each RG object.
I don't care what JSON library to use. I've looked into GSON and Jackson.
Thanks for any advice and ideas...
/ Kim