本文介绍了如何解析JSON响应?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我称之为Web服务,并得到了响应,下面就请告诉我,我该怎么解析.....

  FillAutoCompleteBudgetMasterItemsByMasterIdResponse {
FillAutoCompleteBudgetMasterItemsByMasterIdResult = {anyType的
字符串=农药;字符串=认证费;字符串=咨询;
字符串=合同;字符串=电力;字符串=肥料;字符串=燃料;
字符串=器具及设备;字符串=保险;字符串=灌溉和水资源;
字符串=劳方;字符串=机械使用;字符串=营销;字符串=其他物品;
字符串=后期制作;字符串=维修和保养;字符串=种子/苗;
字符串=服务;字符串=培训;字符串=运输; }; }
 

解决方案

这不是data.Beacuse一个有效的响应应该包含一个(键,值)。通过使用关键我们得到的值。

  JSONArray arObjects =新JSONArray(Respone)的for(int i = 0; I< arObjects.length();我++)
JSONObject的工作= arObjects.getJSONObject(我);
字符串日期= jOb.getString(PublishedDate);
串价格= jOb.getString(导言);
 

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; }; }
解决方案

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");

这篇关于如何解析JSON响应?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-07 00:27