我要做的是创建一个JSONObject,其中包含一个由String组织的其他JSONObject数组?例如,我想创建一个JSONObject,其中包含一个对象数组,这些对象包含也按匹配日期组织的灯具
为您提供我想要实现的目标的视觉参考
JSONObject (JSONArray("Object 10/10/12" {(fixtures content)(fixtures content)}")
("Object 11/10/12" {(fixtures content)(fixtures content)}"))
Run Code Online (Sandbox Code Playgroud)
继续我到目前为止所尝试的但是却无法让它发挥作用
String matchDate1 = null;
JSONArray datesArray = null;
JSONObject fixturesInfo = null;
JSONArray fixturesInfoArray = null;
String matchDateTemp = null;
for(int f = 0; f < fixturesArray.length(); f++){
JSONObject matchDateDict = fixturesArray.getJSONObject(f);
matchDate1 = matchDateDict.getString("matchdate");
JSONArray fixturesInfoDict = fixturesInfo.getJSONArray(matchDate1);
if(fixturesInfoDict == null){
tempArray = null;
} else {
tempArray = fixturesInfoDict;
}
if(matchDateTemp != matchDate1){
fixturesInfoArray.put(matchDate1);
}
matchDateTemp = matchDate1;
tempArray.put(fixturesArray.getJSONObject(f));
fixturesInfo.put(matchDate1, tempArray);
}
Log.v("MyFix", "fixturesInfo …Run Code Online (Sandbox Code Playgroud)