How to nest objects when building JSON with JSONObject

前端 未结 4 1998
梦如初夏
梦如初夏 2021-02-07 20:34

I\'m trying to encode this string for a POST request. Can anyone tell me how I can encode

{\"jsonrpc\": \"2.0\", \"method\": \"Files.GetSources\",         


        
4条回答
  •  一生所求
    2021-02-07 21:39

    Well, if you do have the string before hand, you can simply do

    JSONObject object = JSONObject.getJSONObject("{\"jsonrpc\": \"2.0\", \"method\": \"Files.GetSources\", \"params\":{\"media\":\"music\"}, \"id\": 1}");
    

提交回复
热议问题