create json in android

后端 未结 1 1427
感情败类
感情败类 2020-12-04 17:29

I wish to create json looking like:

{\"man\": 
   {
   \"name\":\"emil\",
   \"username\":\"emil111\",
   \"age\":\"111\" 
   }
}

within an

相关标签:
1条回答
  • 2020-12-04 18:15

    You can put another JSON object inside the main JSON object:

    JSONObject json = new JSONObject();
    JSONObject manJson = new JSONObject();
    manJson.put("name", "emil");
    manJson.put("username", "emil111");
    manJson.put("age", "111");
    json.put("man",manJson);
    
    0 讨论(0)
提交回复
热议问题