Bonjour a tous j'ai besoin d'aide
je suis en plein développement d'une application faite en java et je dois faire un "parsing" d'un objet .json en une classe java.
j'utilise pour ce faire jackson, elle fonctionne très bien mais il y a cependant un petit problème voici le genre de .json que je dois traiter:
{
"root": {
"key": "XXXXXXXXXXX",
"shows": {
"0": {
"url": "the-killing-2011",
"title": "The Killing (2011)"
},
"1": {
"url": "kill-me-baby",
"title": "Kill Me Baby"
},
"2": {
"url": "generationkill",
"title": "Generation Kill"
},
"3": {
"url": "painkillerjane",
"title": "Painkiller Jane"
},
"4": {
"url": "thekillpoint",
"title": "The Kill Point"
},
"5": {
"url": "a-love-to-kill",
"title": "A Love To Kill"
},
"6": {
"url": "giantkilling",
"title": "Giant Killing"
},
"7": {
"url": "he-kills-coppers",
"title": "He Kills Coppers"
},
"8": {
"url": "killer-girl-k",
"title": "Killer Girl K"
},
"9": {
"url": "killerinstinct",
"title": "Killer Instinct"
},
"10": {
"url": "killing-time",
"title": "Killing Time"
},
"11": {
"url": "video-killed-the-radio-star",
"title": "Video Killed The Radio Star"
},
"12": {
"url": "shadowskill",
"title": "Shadow Skill"
}
},
"code": 1,
"errors": {
}
}
}
Le problème que j'ai c'est que le nombre de fils "shows" (dans ce cas ci) est variable suivant la requête faite au serveur.
ma classe java est définie de la manière suivante:
public class Shows {
private ArrayList<Show> showList;
Shows(String...shows){
setShows(shows);
}
Shows(){
}
public void setShows(String... shows){
for(int i = 0; i < shows.length-1; i+=2){
Show temp = new Show(shows[i], shows[i+1]);
showList.add(temp);
}
}
public ArrayList<Show> getShows(){
return this.showList;
}
}
Si l'un de vous peu m'expliquer comment faire pour "parsé" tous les enfants de show dans une arrayList ça m'aiderai beaucoup.
Merci d'avance.
Partager