[
{
"title": "ginger",
"id": "38",
"product_id": "17",
"product_logo": "imagePath/Desert_0.jpg?itok=Uvm6nxpY",
"product_logo_1": "imagePath/Desert_0.jpg?itok=6YHK_afq",
"price": "$12.00"
}
]
I'm working on a swing application in Java in which I need to fetch data from web-service
I'm following this example to get data from web service and it store web service data in String.
But I want to convert this string to json and follow some example one of them is this and this
so I just want to know what I'm doing wrong here, or this is the right way to use this, because I don't know how to use web services in Java...
You need to create its object first and then you need to use this
JSONObject jsnobject = new JSONObject(String);
JSONArray jsonArray = jsnobject.getJSONArray("locations");
for (int i = 0; i < jsonArray.length(); i++) {
JSONObject explrObject = jsonArray.getJSONObject(i);
}
and make sure you import this one in your code org.json.JSONObject
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments