【问题标题】:How do I split these String Arraylist [{ } , {}, { }...] to strings or Integer? [duplicate]如何将这些 String Arraylist [{ } , {}, { }...] 拆分为字符串或整数? [复制]
【发布时间】:2014-10-17 13:58:29
【问题描述】:

我有,

[{"GroupPosition":0,"ChildPosition":0},{"GroupPosition":0,"ChildPosition":1},{"GroupPosition":1,"ChildPosition":0}]

我如何将它们分成: 组位置:

[0,0,1] or {0,0,1}

孩子位置:

[0,0,0] or {0,0,0}

【问题讨论】:

  • @Yuliam Chandra,感谢您编辑了我的主题,帮助我完成了目标。谢谢,谢谢

标签: android expandablelistview data-conversion


【解决方案1】:

您的输入是 json 格式。考虑我的代码是示例。

private static ArrayList<String> array_1 = new ArrayList<String>();;
String json = [{"GroupPosition":0,"ChildPosition":0},{"GroupPosition":0,"ChildPosition":1},{"GroupPosition":1,"ChildPosition":0}];
JSONArray leagues = new JSONArray(json);
for (int i = 0; i < leagues.length(); i++) {
JSONObject obj = leagues.getJSONObject(i);
array_1.add(obj.getString("GroupPosition"));
}

【讨论】:

  • 非常感谢 Amsheer。它非常接近我想要的。你真的是最伟大的人之一。哎呀,我不知道有这样的话题,因为我还是 Android 新手,不知道它叫什么...... PARSE 明白了。 -7 到我的帐户 WOW
  • 反对票和赞成票无关紧要。当您在这里提出问题时,只需解释您的问题是什么。你尝试过的所有事情是什么。这会对你有所帮助。
  • 90% 的人使用 json 来开发 android 应用程序。但是大多数人不明白你的问题。继续尝试。祝你好运
猜你喜欢
  • 1970-01-01
  • 2021-12-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-10-17
  • 2019-06-11
相关资源
最近更新 更多