0

I am facing a problem to reach to an object which is inside an array of another object of another array. To make it simpler i am attaching the image (attached below), basically i want to reach to json object "0" inside jsonarray ticket itmes.

my codes are

 JSONArray jsonArray = new JSONArray(buffer.toString());
 JSONObject jsonobject = null;

 jsonobject = jsonArray.getJSONObject(0);

 JSONArray jsonarray1 = new JSONArray(buffer.toString());

 jsonarray1 = jsonobject.getJSONArray("ticketitems");



 JSONObject jsonobject1 = null;

  TicketItem ticketItemList = new TicketItem();

  jsonobject1 = jsonArray.getJSONObject(0);

  ticketItemList.setItemCount(jsonobject1.getInt("itemCount"));

  TicketItemList.add(ticketItemList);

However, jsonarray1 generates an exception stating

org.json.JSONException: No value for ticketitems

enter image description here

2 Answers 2

1

replace

jsonarray1 = jsonobject.getJSONArray("ticketitems");

with

jsonarray1 = jsonobject.getJSONArray("ticketItems");
Sign up to request clarification or add additional context in comments.

Comments

0

It's case sensitive. It should be

jsonarray1 = jsonobject.getJSONArray("ticketItems");

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.