現在Gsonを使ってJsonのデーターをパースしようとしています。いろんなWebサイトを見て基本的な値の取得の仕方はわかったのですが、今回使用するJsonはキーの名前が毎回変化していくものを使用します。
そのため、どう取得していいのかわかりません。
今回使用するJsonは下記のようになイメージです。
lang
1{ 2 "work"{ 3 "boxes"{ 4 "state":{ 5 "memo":"" 6 "type":"hoge" 7 "branch":[ 8 { 9 "box15095203386196257595" 10 } 11 ] 12 }, 13 "box15095203386196257595": { 14 "name": "hoge", 15 "old": "11", 16 "next":"box156196257134595" 17 18 } 19 "box7509526251457595": { 20 "name": "huge", 21 "old": "54", 22 "next":"box42295203386257595" 23 } 24 25 "box560903386196257595": { 26 "name": "hoho", 27 "old": "18", 28 "next":"box7509526251457595" 29 } 30 "box156196257134595": { 31 "name": "tarou", 32 "old": "23", 33 "next":"box560903386196257595" 34 } 35 "box42295203386257595": { 36 "name": "yamada", 37 "old": "30", 38 "next":"" 39 } 40 } 41 } 42}
私が試してみたことは初めのBOXの名前だけでも取得することができないかと試してみました
lang
1class Boxes { 2 public Stanby stanby; 3 public List<String> BoxList; 4 5 public Boxes(Stanby stanby) { 6 this.stanby = stanby; 7 GetBuildId(stanby); 8 } 9 10 private void GetBuildId(Stanby stanby) { 11 BoxList.add(this.stanby.branches.get(0).next.toString()); 12 } 13} 14
上記のコードを試して見たのですが、BoxListの値に追加がされておらずnullになっていました。
どうしたら値を取得することができるのでしょうか
回答1件
あなたの回答
tips
プレビュー