Questions tagged «jsonobject»

7
将ArrayList <MyCustomClass>转换为JSONArray
我有一个ArrayList,可在ArrayAdapter中用于ListView。我需要将列表中的项目转换为JSONArray才能发送到API。我四处搜寻,但没有找到任何说明其工作方式的信息,我们将不胜感激。 更新-解决方案 这就是我最终要解决的问题。 ArrayList中的对象: public class ListItem { private long _masterId; private String _name; private long _category; public ListItem(long masterId, String name, long category) { _masterId = masterId; _name = name; _category = category; } public JSONObject getJSONObject() { JSONObject obj = new JSONObject(); try { obj.put("Id", _masterId); obj.put("Name", _name); …
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.