简体   繁体   English

如何解析JSON响应?

[英]How to parse JSON response?

I have called webservice and got a response as below please tell me how can I parse it..... 我已经打电话给webservice并收到如下回复,请告诉我如何解析它.....

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; }; }

This not a valid Response data.Beacuse it should contain a (key,value). 这不是有效的响应数据。因为它应该包含(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");

This is not a valid json. 这不是有效的json。 The strings are not quoted. 字符串不加引号。

http://json.org/example.html http://json.org/example.html

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 这不是有效的json格式。.您不能使用Json进行解析...如果字符串不是有效的json格式,则会引发异常...括起来的[]中的字符串括在被称为josn数组中。 {}中被称为josn对象的括号..一般的json数组包含josn对象

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

This tutorial might help you to parse the json in an easy and hassle free way. 本教程可能会帮助您以一种简单而轻松的方式来解析json。 Please check this out. 请检查出来。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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