Below is the response I get from the API.
[{
"claim1": [{
"claim_no": "1",
"claim_date": "14\/06\/2017 12:00:00 AM",
"month_code": "1",
"claim_amount": "8074"
}]
}, {
"billing1": [{
"claim_no": "141",
"month_code": "1",
"miti": "6",
"amount": "7374",
"paid": "7374",
"fee1": "0"
}]
}, {
"claim2": [{
"claim_no": "26",
"claim_date": "20\/06\/2017 12:00:00 AM",
"month_code": "2",
"claim_amount": "2424"
}]
}, {
"billing2": []
}, {
"claim3": [{
"claim_no": "40",
"claim_date": "13\/07\/2017 12:00:00 AM",
"month_code": "3",
"claim_amount": "2924"
}]
}, {
"billing3": [{
"claim_no": "724",
"month_code": "3",
"miti": "13",
"amount": "2924",
"paid": "2924",
"fee1": "0"
}]
}, {
"claim4": [{
"claim_no": "43",
"claim_date": "09\/08\/2017 12:00:00 AM",
"month_code": "4",
"claim_amount": "2424"
}]
}, {
"billing4": [{
"claim_no": "402",
"month_code": "4",
"miti": "20",
"amount": "5348",
"paid": "3124",
"fee1": "0"
}]
}]
I am using the aQuery jsonarray class.
I tried to get it in a JSON object, but got an error like
jsonarray cannot be converted to jsonobject
below is my code.
This code is showing me this error
"org.json.JSONException: No value for claim_no"
I want to get the value of claim_no
aq.ajax("myapiurlhere", JSONArray.class, new AjaxCallback<JSONArray>(){
#Override
public void callback(String url, JSONArray array, AjaxStatus status) {
super.callback(url, array, status);
Log.i("response:", "response:" + url + array);
for (int i = 0; i < array.length(); i++) {
try {
JSONObject object = array.getJSONObject(i);
bill_no = object.getString("claim_no");
Log.i("response:","claim: "+claim_no+" bill: "+object);
} catch (JSONException e) {
e.printStackTrace();
}
}
}
});
I also tried the code below, but I got an error
"claim1 of type org.json.JSONArray cannot be converted to JSONObject"
aq.ajax("myapiurl", JSONArray.class, new AjaxCallback<JSONArray>(){
#Override
public void callback(String url, JSONArray array, AjaxStatus status) {
super.callback(url, array, status);
Log.i("response:", "response:" + url + array);
for (int i = 0; i < array.length(); i++) {
try {
int mycount = i+1;
JSONObject object = array.getJSONObject(i);
JSONObject claimobject = object.getJSONObject("claim"+mycount);
claim_no = claimobject.getString("claim_no");
Log.i("response:","claim: "+claim_no);
} catch (JSONException e) {
e.printStackTrace();
}
}
}
});
This is an array
"claim1": [
You're getting an object
JSONObject claimobject = object.getJSONObject("claim"+mycount);
You need to get an array first
JSONObject claimobject = object.getJSONArray("claim"+mycount).getJSONObject(0);
Also, your API is poorly structured, and int mycount = i+1; will likely fail because you're counting billing and claim elements at the same time
Try this instead
for (int i = 0; i < array.length(); i++) {
int mycount = (i/2)+1;
try {
Related
I am trying to parse this URL : http://testproject1.indigierp.com/api/banner_details with POST request. This is the response returned :
{
"msg": true,
"src": [
{
"id": 12,
"banner_name": "https://testproject1.indigierp.com/images/banners/promo1.jpg",
"user_id": "1",
"created_at": "2021-09-22 21:46:04",
"updated_at": "-0001-11-30 00:00:00"
},
{
"id": 14,
"banner_name": "https://testproject1.indigierp.com/images/banners/promo3.jpg",
"user_id": "1",
"created_at": "2021-09-22 21:46:16",
"updated_at": "-0001-11-30 00:00:00"
},
{
"id": 15,
"banner_name": "https://testproject1.indigierp.com/images/banners/promo4.jpg",
"user_id": "1",
"created_at": "2021-09-22 21:46:28",
"updated_at": "-0001-11-30 00:00:00"
},
{
"id": 16,
"banner_name": "https://testproject1.indigierp.com/images/banners/promo4.jpg",
"user_id": "1",
"created_at": "2021-09-23 03:30:41",
"updated_at": "-0001-11-30 00:00:00"
},
{
"id": 17,
"banner_name": "https://testproject1.indigierp.com/images/banners/discountberry.png",
"user_id": "1",
"created_at": "2021-09-23 03:32:37",
"updated_at": "-0001-11-30 00:00:00"
}
]
}
Now, on my Android App only the first 2 data (JSON Object ) is shown. This is my Android code :
JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.POST, BANNER_URL, null, response -> {
for (int i = 0; i < response.length(); i++) {
try {
JSONArray jsonArray = response.getJSONArray("src");
JSONObject jsonObject = jsonArray.getJSONObject(i);
Log.e("OBJ Size", String.valueOf(jsonObject.length()));
String bannerName = jsonObject.getString("banner_name");
Log.e("BNAME", bannerName);
sliderModelList.add(new SliderModel(bannerName));
sliderAdapter.notifyDataSetChanged();
} catch (JSONException e) {
e.printStackTrace();
Log.e("JSOnException", e.getLocalizedMessage());
}
I debugged as well. The Log.e OBJ Size returns 5 which is correct , but the next line Log.e("BNAME", bannerName); returns only the first 2 items .
What is wrong here, Please try to help me fix it. Thanks :)
Check with this
for (int i = 0; i < response.length(); i++) {
try {
JSONArray jsonArray = response.getJSONArray("src");
for(int j=0;j<jsonArray.length();j++){
JSONObject jsonObject = jsonArray.getJSONObject(j);
Log.e("OBJ Size", String.valueOf(jsonObject.length()));
String bannerName = jsonObject.getString("banner_name");
Log.e("BNAME", bannerName);
sliderModelList.add(new SliderModel(bannerName));
sliderAdapter.notifyDataSetChanged();
}
} catch (JSONException e) {
e.printStackTrace();
Log.e("JSOnException", e.getLocalizedMessage());
}
response.length() returns "2", because there are 2 fields in the response: "msg" and "src". You're doing the for on a wrong object.
Get the array first, then enumerate it:
JSONArray jsonArray = response.getJSONArray("src");
for (int i = 0; i < jsonArray.length(); i++) {
JSONObject jsonObject = jsonArray.getJSONObject(i);
...
In my Android app, I am fetching the details of Points table of a tournament to convert the output to a string from JSON object to Java
JSON object is shown below:
{
"group": {
"Teams": [
{
"name": "Team 1",
"p": "10",
"w": "9",
"l": "1",
"points": "18"
},
{
"name": "Team 2",
"p": "10",
"w": "9",
"l": "1",
"points": "18"
},
{
"name": "Team 3",
"p": "10",
"w": "9",
"l": "1",
"points": "18"
},
{
"name": "Team 4",
"p": "10",
"w": "6",
"l": "4",
"points": "12"
},
{
"name": "Team 5",
"p": "10",
"w": "6",
"l": "4",
"points": "12"
},
{
"name": "Team 6",
"p": "10",
"w": "6",
"l": "4",
"points": "12"
},
{
"name": "Team 7",
"p": "10",
"w": "5",
"l": "5",
"points": "11"
},
{
"name": "Team 8",
"p": "10",
"w": "5",
"l": "5",
"points": "11"
}
]
}
}
Android Java Code is below:
JSONObject match = new JSONObject(response);
if (match.has("group")) {
JSONObject group = match.getJSONObject("group");
if (match.has("Teams")) {
JSONObject teams = group.getJSONObject("Teams");
if (teams.has("0")) {
JSONObject teams_object = teams.getJSONObject("0");
String team_name = teams_object.getString("name");
String matches_played = teams_object.getString("p");
String matches_won = teams_object.getString("w");
String matches_lost = teams_object.getString("l");
String points = teams_object.getString("points");
}
}
}
But I am getting the error where I print the error message through getMessage() method. Here is the error below:
Error: Value ["name","p","w","l","points"] at header of type org.json.JSONArray cannot be converted to JSONObject
Can anyone please help like where I am going wrong or what is the fix ? Thanks in advance
In your Json Teams holds the Array of Object and you are parsing wrong.
Try this
JSONObject jsonObject = new JSONObject(response);
JSONObject groups = jsonObject.getJSONObject("group");
JSONArray teams = groups.getJSONArray("Teams");
for(int i=0;i<teams.length();i++){
JSONObject obj = teams.getJSONObject(i);
name.append(obj.getString("name")+"\n");
}
There is 4 mistakes in your code,
1.You have to check whether group has teams instead match has teams.
2.You have to get team as JSONArray instead of JSONObject because it is array.
3.You have to check the size of team, instead of find the object with key 0, there is no object with name 0 in your group,
4.You have to get the object based on index instead of key(ie., 0)
Please check the working code, this is tested
try {
JSONObject match = new JSONObject(response);
if (match.has("group")) {
JSONObject group = match.getJSONObject("group");
if (group.has("Teams")) {
JSONArray teams = group.getJSONArray("Teams");
if (teams.length() > 0) {
JSONObject teams_object =(JSONObject) teams.get(0);
String team_name = teams_object.getString("name");
String matches_played = teams_object.getString("p");
String matches_won = teams_object.getString("w");
String matches_lost = teams_object.getString("l");
String points = teams_object.getString("points");
Log.v(TAG, team_name);
}
}
}
} catch (JSONException e) {
e.printStackTrace();
}
try {
JSONObject jsonObject = new JSONObject(response.body().string());
JSONObject subObject = jsonObject.getJSONObject("group") ;
JSONArray jsonArray = subObject.getJSONArray("Teams");
for (int i=0; i<jsonArray.length(); i++){
JSONObject object = jsonArray.getJSONObject(i);
String name = jsonObject.getString("name");
String p= jsonObject.getString("p");
String w= jsonObject.getString("w");
String l= jsonObject.getString("l");
String points = jsonObject.getString("points");
}
} catch (Exception e) {
e.printStackTrace();
}
if (match.has("group")) {
JSONObject group = match.getJSONObject("group");
if (match.has("Teams")) {
JSONArray teams = group.getJSONArray("Teams");
// for only 0th element use below code else looping
JSONObject teams_object = (JSONObject) teams.get(0);
String team_name = teams_object.getString("name");
String matches_played = teams_object.getString("p");
String matches_won = teams_object.getString("w");
String matches_lost = teams_object.getString("l");
String points = teams_object.getString("points");
}
}
Error: Value ["name","p","w","l","points"] at header of type
org.json.JSONArray cannot be converted to JSONObject
You are getting the error because there is an Array of Teams and you are trying parse with JSONObject
Please check below code snippet. It will work.
try {
JSONObject match = new JSONObject("your_response");
if (match.has("group")) {
JSONObject group = match.getJSONObject("group");
if (group.has("Teams")) {
JSONArray teams = group.getJSONArray("Teams");
for(int i=0; i < teams.length(); i++){
JSONObject teams_object = (JSONObject) teams.get(i);
String team_name = teams_object.getString("name");
String matches_played = teams_object.getString("p");
String matches_won = teams_object.getString("w");
String matches_lost = teams_object.getString("l");
String points = teams_object.getString("points");
}
}
}
} catch (JSONException e) {
e.printStackTrace();
}
Try this #SaAsh, I have just edited by taking your answer
if (match.has("group")) {
JSONObject group = match.getJSONObject("group");
if (match.has("Teams")) {
JSONObject teams = group.getJsonArray("Teams");
for(int i = 0 ; i < teams.length();i++){
JSONObject teams_object = teams.getJSONObject("i");
String team_name = teams_object.getString("name");
String matches_played = teams_object.getString("p");
String matches_won = teams_object.getString("w");
String matches_lost = teams_object.getString("l");
String points = teams_object.getString("points");
}
}
}
}
I have this json
{
"results": [
{
"user": {
"gender": "male",
"name": {
"title": "mr",
"first": "herbert",
"last": "davidson"
},
"location": {
"street": "9763 fincher rd",
"city": "melbourne",
"state": "new south wales",
"zip": 26278
},
"email": "herbert.davidson#example.com",
"username": "lazyelephant581",
"password": "abgrtyu",
"salt": "O8ZbSsUL",
"md5": "7575bd959be09bc6d510a6a91750ce40",
"sha1": "0db99de8402e1defbd7935dbd602d99329698d4d",
"sha256": "c283d262115f90b729bb555db3dbecc8d27eebed513d7f01da799dec9e9d3269",
"registered": 1275070071,
"dob": 122409280,
"phone": "05-5742-3228",
"cell": "0481-652-548",
"TFN": "973720989",
"picture": {
"large": "https://randomuser.me/api/portraits/men/24.jpg",
"medium": "https://randomuser.me/api/portraits/med/men/24.jpg",
"thumbnail": "https://randomuser.me/api/portraits/thumb/men/24.jpg"
}
}
}
],
"nationality": "AU",
"seed": "0a69317ece7072e000",
"version": "0.7"
}
and im doing this:(result is the json returned from the service)
try{
JSONObject jsonResponse = new JSONObject(result);
JSONObject jo = jsonResponse.getJSONObject("user");
String nome = jo.getString("username");
}catch(Exception e) {
e.printStackTrace();
}
but gives me this error
org.json.JSONException: No value for username
What im doing wrong? I tryed to do a JSONArray, tryed to get the jsonobject from another jsonobject, but giver an error that cannot convert jsonobject to a jsonarray.
regards!
Rafael
Try this in your code .
try {
JSONObject jsonObject = new JSONObject(response);
JSONArray results = jsonObject.getJSONArray("results");
for (int i = 0; i < results.length(); i++) {
JSONObject jo = results.getJSONObject(i);
JSONObject user = jo.getJSONObject("user");
String username = user.optString("username");
}
} catch (JSONException e) {
e.printStackTrace();
}
Use optString in your code .If your username is null,it will not return error .
The first-level key in your dictionary is "results", not "user". Also, results is an array, so you have to index into that.
You're trying to access: user->username
You need to access: results[0]->user->username
I have a JSON array, and I want to sort it Depending on the name and too alphabetically.
My Json is as follows.
[
{
"UserID": 77,
"InvID": 333,
"Email": "sumeetssm#gmail.com",
"Phone": "",
"Name": "Summet",
"Company": "",
"Date": "2014-01-14T00:00:00"
},
{
"UserID": 0,
"InvID": 334,
"Email": "amit#testt.com",
"Phone": "",
"Name": "Amit",
"Company": "",
"Date": "2014-01-14T00:00:00"
},
{
"UserID": 3,
"InvID": 335,
"Email": "amitesh#yahoo.com",
"Phone": "",
"Name": "Amitesh",
"Company": "",
"Date": "2014-01-14T00:00:00"
},
{
"UserID": 0,
"InvID": 336,
"Email": "foobar#test.com",
"Phone": "",
"Name": "FOO",
"Company": "",
"Date": "2014-01-14T00:00:00"
},
{
"UserID": 0,
"InvID": 337,
"Email": "krazy.lance#gmail.com",
"Phone": "",
"Name": "Krazy",
"Company": "",
"Date": "2014-01-14T00:00:00"
},
{
"UserID": 1,
"InvID": 338,
"Email": "test#yahoo.com",
"Phone": "",
"Name": "Test",
"Company": "",
"Date": "2014-01-14T00:00:00"
},
{
"UserID": 0,
"InvID": 339,
"Email": "maktest#yahoo.com",
"Phone": "",
"Name": " ",
"Company": "",
"Date": "2014-01-14T00:00:00"
},
{
"UserID": 0,
"InvID": 340,
"Email": "Sam#rediff.com",
"Phone": "",
"Name": "SAM",
"Company": "",
"Date": "2014-01-14T00:00:00"
},
{
"UserID": 101,
"InvID": 343,
"Email": "anurag#yahoo.com",
"Phone": "",
"Name": "Anurag",
"Company": "",
"Date": "2014-01-14T00:00:00"
},
{
"UserID": 95,
"InvID": 379,
"Email": "s#s.com",
"Phone": "",
"Name": "S",
"Company": "",
"Date": "2014-01-14T00:00:00"
},
{
"UserID": 0,
"InvID": 428,
"Email": "sumeetssm#yahoo.com",
"Phone": "",
"Name": "Summet",
"Company": "",
"Date": "2014-01-16T00:00:00"
},
{
"UserID": 4,
"InvID": 494,
"Email": "sameer#iconnectgroup.com",
"Phone": "",
"Name": "Sameer P",
"Company": "",
"Date": "2014-01-21T00:00:00"
},
{
"UserID": 85,
"InvID": 507,
"Email": "jonny#dep.com",
"Phone": "9404988188",
"Name": "Jonny Dep",
"Company": "Iconnect",
"Date": "2014-01-22T00:00:00"
}
]
As you can see I have a key value "Name" and in that I get respected names. I want to sort this Json array completely based on this names and that too alphabetically.Thanks in advance.
Convert JSONArray to Arraylist<JSONBbject> and use Collections to sort your arraylist
for example :
ArrayList<JSONObject> array = new ArrayList<JSONObject>();
JSONArray jsonArray = new JSONArray();
for (int i = 0; i < jsonArray.length(); i++) {
try {
array.add(jsonArray.getJSONObject(i));
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Collections.sort(array, new Comparator<JSONObject>() {
#Override
public int compare(JSONObject lhs, JSONObject rhs) {
// TODO Auto-generated method stub
try {
return (lhs.getString("Name").toLowerCase().compareTo(rhs.getString("Name").toLowerCase()));
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return 0;
}
}
});
Firstly, parse the json data and add every json object to List of Object (e.g. Employee)
List<Employee> employees = parseJson(jsonDate);
Collections.sort(employees, new EmployeeComparator());
Here is the comparator implementation:
class EmployeeComparator implements Comparator<Employee> {
#Override
public int compare(Employee o1, Employee o2) {
return o1.getName().compareTo(o2.getName());
}
}
// try this way i have gave demo code you have modify as per your requirement.
public class MyActivity extends Activity {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
try{
JSONArray jsonArray = new JSONArray();
JSONObject jsonObject = new JSONObject();
jsonObject.put("name","Haresh");
JSONObject jsonObject1 = new JSONObject();
jsonObject1.put("name","Akash");
JSONObject jsonObject2 = new JSONObject();
jsonObject2.put("name","Biraj");
JSONObject jsonObject3 = new JSONObject();
jsonObject3.put("name","Salim");
JSONObject jsonObject4 = new JSONObject();
jsonObject4.put("name","Saloni");
jsonArray.put(jsonObject1);
jsonArray.put(jsonObject);
jsonArray.put(jsonObject3);
jsonArray.put(jsonObject2);
jsonArray.put(jsonObject4);
ArrayList<HashMap<String,String>> list = (ArrayList<HashMap<String,String>>)toList(jsonArray);
Collections.sort(list,new Comparator<HashMap<String, String>>() {
#Override
public int compare(HashMap<String, String> stringStringHashMap, HashMap<String, String> stringStringHashMap2) {
return stringStringHashMap.get("name").compareTo(stringStringHashMap2.get("name"));
}
});
for (HashMap<String,String> row : list){
System.out.println("Row :"+row.get("name"));
}
}catch (Exception e){
e.printStackTrace();
}
}
private Object fromJson(Object json) throws JSONException {
if (json == JSONObject.NULL) {
return null;
} else if (json instanceof JSONObject) {
return jsonToMap((JSONObject) json);
} else if (json instanceof JSONArray) {
return toList((JSONArray) json);
} else {
return json;
}
}
public Map<String, String> jsonToMap(JSONObject object) throws JSONException {
Map<String, String> map = new HashMap();
Iterator keys = object.keys();
while (keys.hasNext()) {
String key = (String) keys.next();
map.put(key, fromJson(object.get(key)).toString());
}
return map;
}
#SuppressWarnings({ "rawtypes", "unchecked" })
private List toList(JSONArray array) throws JSONException {
List list = new ArrayList();
int size = array.length();
for (int i = 0; i < size; i++) {
list.add(fromJson(array.get(i)));
}
return list;
}
}
JSONArrays are not sortable. You can extract the data into an ArrayList and then sort with a comparator and then put back into the JSONArray.
On the Android side you generally won't sort objects in JSON format. If they do need to be sorted before you retrieve them, that is something that should occur on the backend.
Alternatively, and this is very common, you will parse the JSON objects into local Java objects (or Collections of objects), and then you can use a comparator to sort the collection based on a certain property that exists within all objects in the collection.
Fortunately both of these tasks have been asked and answered many times before. For more information on parsing JSON see How to parse JSON in Android. For more information on sorting objects in a collection see Android-java- How to sort a list of objects by a certain value within the object.
I am parsing some JSON that has arrays within arrays, and I just cant seem to get the data of the arrays within the first array.
My JSON looks like this (I cut it off in the end so it wasn't that long):
{"TrackingInformationResponse": {
"shipments": [
{
"shipmentId": "03015035146308",
"uri": "\/ntt-service-rest\/api\/shipment\/03015035146308\/0",
"assessedNumberOfItems": 1,
"deliveryDate": "2013-05-13T11:47:00",
"estimatedTimeOfArrival": "2013-05-13T16:00:00",
"service": {
"code": "88",
"name": "DPD"
},
"consignor": {
"name": "Webhallen Danmark ApS",
"address": {
"street1": "Elsa Brändströms Gata 52",
"city": "HÄGERSTEN",
"countryCode": "SWE",
"country": "Sverige",
"postCode": "12952"
}
},
"consignee": {
"name": "Lene Bjerre Kontor & IT Service",
"address": {
"street1": "Lene Bjerre",
"street2": "Ørbækvej 8, Hoven",
"city": "TARM",
"countryCode": "???",
"postCode": "6880"
}
},
"statusText": {
"header": "Forsendelsen er udleveret",
"body": "Forsendelsen blev leveret 13-05-2013 kl. 11:47"
},
"status": "DELIVERED",
"totalWeight": {
"value": "0.55",
"unit": "kg"
},
"totalVolume": {
"value": "0.005",
"unit": "m3"
},
"items": [
{
"itemId": "03015035146308",
"dropOffDate": "2013-05-08T17:18:00",
"deliveryDate": "2013-05-13T11:47:00",
"status": "DELIVERED",
"statusText": {
"header": "Forsendelsen er udleveret til modtageren",
"body": "Forsendelsen blev udleveret 13-05-2013 kl. 11:47"
},
I can get the content of the "shipments" array just fine, but I have no idea how to get the contents of the "items" array. My code looks like this:
try {
JSONObject jsonObject = new JSONObject(result);
JSONObject TrackingInformationResponse = new JSONObject(jsonObject.getString("TrackingInformationResponse"));
JSONArray shipments = new JSONArray(TrackingInformationResponse.getString("shipments"));
for (int i = 0; i < shipments.length(); i++) {
JSONObject JSONitems = shipments.getJSONObject(i);
String shipmentId = JSONitems.getString("shipmentId");
//do stuff
}
} catch (Exception e) {
Log.d("ReadWeatherJSONFeedTask", e.getLocalizedMessage());
}
How would I do the same with the "items" array as I did with the "shipments" array?
You have to get the items array from inside the Shipment array, like you did the shipments, then iterate through that, like you did the shipments.
It might look something like:
JSONObject jsonObject = new JSONObject(result);
JSONObject TrackingInformationResponse = new JSONObject(jsonObject.getString("TrackingInformationResponse"));
JSONArray shipments = new JSONArray(TrackingInformationResponse.getString("shipments"));
for (int i = 0; i < shipments.length(); i++) {
JSONObject JSONitems = shipments.getJSONObject(i);
String shipmentId = JSONitems.getString("shipmentId");
JSONArray items = new JSONArray(JSONitems.getString("items");
//get items stuff
//do stuff
}
} catch (Exception e) {
Log.d("ReadWeatherJSONFeedTask", e.getLocalizedMessage());
}
items is a JSON Array located inside the shipments array, so you need to get the items array within the shipments, maybe like this :
for (int i = 0; i < shipments.length(); i++) {
JSONObject JSONitems = shipments.getJSONObject(i);
String shipmentId = JSONitems.getString("shipmentId");
JSONArray items = new JSONArray(JSONitems.getString("items"));
//iterate over items
}
Hope this helps, Good luck
Try bellow code:
JSONObject jObject = new JSONObject(yourJSONString);
JSONObject trackInfo = jObject.getJSONObject("TrackingInformationResponse");
JSONArray shipMents = trackInfo.getJSONArray("shipments");
JSONArray items = shipMents.getJSONArray("items");