0

我想要做:

(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);   

并且有很多日期对象,请帮助..

4

1 回答 1

0

您可以使用捆绑的 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。

于 2013-07-07T14:14:02.263 回答