简体   繁体   中英

I am trying to retrieve data from a particular JSON object situated in an array, but i cannot access the individual items within the "value" object

"items": [
    {
      "day": 1,
      "mealPlanId": 0,
      "slot": 1,
      "position": 0,
      "type": "RECIPE",
      "value": "{\"id\":913380,\"imageType\":\"jpg\",\"title\":\"Baked Cherry French Toast Casserole\"}"
    },

I can retrieve "value" in the form of

{"id":657306,"imageType":"jpg","title":"Pumpkin French Toast"}

But how can i individually separate them for example, title would = "Baked Cherry French Toast Casserole" I am using the org.json library Thanks for your help!

You can just cast your value string in json object with org.json library. Then access to all the field via this json object.

To transform your value string in JSON object with org.json

JSONObject jo = new JSONObject("yourValue");

look https://www.baeldung.com/java-org-json for more documentation

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM