user1791327
user1791327

Reputation:

How to parse JSON response?

I have called webservice and got a response as below please tell me how can I parse it.....

FillAutoCompleteBudgetMasterItemsByMasterIdResponse{
FillAutoCompleteBudgetMasterItemsByMasterIdResult=anyType{
string=Agrochemicals; string=Certification fee; string=Consultation; 
string=Contracts; string=Electricity; string=Fertilizers; string=Fuel;
string=Implements and Equipments; string=Insurance; string=Irrigation and Water;
string=Labours; string=Machinery usage; string=Marketing; string=Other Items; 
string=Post Production; string=Repairs and Maintenance; string=Seeds/Seedlings ;
string=Services; string=Training; string=Transportation; }; }

Upvotes: 0

Views: 213

Answers (4)

sandeep
sandeep

Reputation: 481

This not a valid Response data.Beacuse it should contain a (key,value). By using key we get the value.

JSONArray arObjects = new JSONArray(Respone);for(int i = 0; i < arObjects.length(); i++)
JSONObject jOb =  arObjects.getJSONObject(i);                       
String date = jOb.getString("PublishedDate");
String price = jOb.getString("introduction");

Upvotes: 4

kittu88
kittu88

Reputation: 2461

This tutorial might help you to parse the json in an easy and hassle free way. Please check this out.

Upvotes: 0

goodfriend0
goodfriend0

Reputation: 303

This is not a valid json. The strings are not quoted.

http://json.org/example.html

Upvotes: 2

Sandeep P
Sandeep P

Reputation: 4411

this is not valid json format.. you cant parse using Json... if the string is not in the valid json format it throws an exception ... The String in enclosed [] braces in called josn array.. The String in enclosed {} braces in called josn object.. in general json array contain josn objects

JSONArray array= new JSONArray(jsonString);
for(i=0;i< array.length ;i++){
   JSONObject result = new JSONObject(array.get(i));
}

Upvotes: 1

Related Questions