-1
我JSONArray
包含各種JSONObject
S的這個樣子:如何從JSONObject中檢索字符串數組?
{"nearby":0,"x":0,"name":["OPS","BHU"],"y":0}
{"nearby":0,"x":0,"name":["None"],"y":1}
{"nearby":0,"x":0,"name":["None"],"y":2}
{"nearby":0,"x":0,"name":["None"],"y":3}
{"nearby":0,"x":0,"name":["None"],"y":4}
{"nearby":0,"x":0,"name":["None"],"y":5}
{"nearby":0,"x":0,"name":["None"],"y":6}
{"nearby":0,"x":1,"name":["None"],"y":0}
{"nearby":0,"x":1,"name":["None"],"y":1}
{"nearby":0,"x":1,"name":["None"],"y":2}
{"nearby":0,"x":1,"name":["DDF","THG"],"y":3}
{"nearby":0,"x":1,"name":["None"],"y":4}
{"nearby":0,"x":1,"name":["None"],"y":5}
{"nearby":1,"x":1,"name":["ABC","DEF","XYZ"],"y":6}
我想在JSONObject
,並從這樣一個數組來檢索對應於name
鍵值:
JSONObject jo= jsonArray.getJSONObject(i);
String nearby= jo.getString("nearby");
String xString= jo.getString("x");
int x=Integer.parseInt(xString);
String yString= jo.getString("y");
int y=Integer.parseInt(yString);
String[][] name=new String[7][7];
name[x][y]= ????????
使得輸出是像:
name[0][0]=["OPS","BHU"]
name[0][1]=["None"]
name[0][2]=["None"]
name[0][3]=["None"]
name[0][4]=["None"]
name[0][5]=["None"]
name[0][6]=["None"]
name[1][0]=["None"]
name[1][1]=["None"]
name[1][2]=["None"]
name[1][3]=["DDF","THG"]
name[1][4]=["None"]
name[1][5]=["None"]
name[1][6]=["ABC","DEF","XYZ"]
請提供[MCVE] - 確保將其減少到最低限度* *,但完整的例子,以及格式。 –