[英]Create Structure JSON in Android/Java
我想要做:
(Object)Date:
(Object)HomeTeam:
(Array)Name
(Array)Num
(Object)AwayTeam:
(Array)Name
(Array)Num
(Object)Date:
(Object)HomeTeam:
(Array)Name
(Array)Num
(Object)AwayTeam:
(Array)Name
(Array)Num
(Object)Date:
(Object)HomeTeam:
(Array)Name
(Array)Num
(Object)AwayTeam:
(Array)Name
(Array)Num
到目前為止,我試圖:
JSONObject json = new JSONObject();
JSONObject home = new JSONObject();
JSONObject away = new JSONObject();
json.put("Date", xxx); I dun know how to do
json.put("HomeTeam", home);
json.put("AwayTeam", away);
並且有很多約會對象,請幫忙。
您可以使用捆綁的JSON庫實現此目的。 要獲得此結構:
(Object)Date:
(Object)HomeTeam:
(Array)Name
(Array)Num
您執行JSONObject date = new JSONObject();
JSONObject team = new JSONObject();
team.put("Name", new JSONArray());
team.put("Name", new JSONArray());
date.put("id", team);
並不是每個節點的"id"
都應該不同,否則您應該在那里切換到JSONArray。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.