i have file and i try to parse it and create custome adapter for view data in list view
@Item
{"name":"item1", "id":1}
{"name":"item2", "id":2}
@Objects
{"name":"item1", "id":1}
{"name":"item2", "id":2}
I try this
String str = " @Item
{"name":"item1", "id":1}
{"name":"item2", "id":2}
@Objects
{"name":"item1", "id":1}
{"name":"item2", "id":2}";
str.replace("@item", "[\"item\":").replace("}{", "}, {");
str = str + "]";
Convert json to java object after that modify the values of it. You can use Gson , to perform conversation.
You should use JSONObject
Create JSON object:
JSONObject myObj = new JSONObject();
myObj.put("name" , "value1" );
myObj.put("id","value2");
Then you can easy to edit your JSON objects data like this
myObj.getString("name" , "update_value1");
myObj.getString("id" , "update_value2");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.