如何解析JSON响应?JSON

2023-09-04 04:35:01 作者:Tonight【今夜】

我称之为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(导言);
 
Go Web编程 解析JSON请求和生成JSON响应

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