How to nest objects when building JSON with JSONObject

前端 未结 4 674
你的背包
你的背包 2021-02-07 20:52

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:35

    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}");
    

提交回复
热议问题