解析接口返回的jason数据

待解析Jason数据
{
   "msgbody":"[
      {
         \"accountId\":\"1-LNWRUOI\",
         \"accountIdNumber\":\"3301821984*****626\",
         \"accountIdType\":\"身份证\",
         \"accountManager\":null,
         \"accountManagerPhone\":null,
         \"accountName\":\"方艳丹\",
         \"accountNumber\":\"171100010****989\",
         \"addFlag\":\"N\",
         \"addRelationId\":null,
         \"additionalFlag\":\"N\",
         \"addr97Id\":null,
         \"agreementId\":null,
         \"assembeServiceAddress\":null,
         \"assetDescription\":null,
         \"assetExtendDescText\":\"\",
         \"assetExtendValue\":\"\",
         \"assetGrade\":null,
         \"assetPromDtoList\":null,
         \"assetXaList\":null,
         \"assurerId\":null,
         \"billAccountId\":\"3-6FKFYZX\",
         \"billAccountName\":\"方艳丹\",
         \"billAccountNum\":\"2711045***05\",
         \"billStatus\":\"计费成功\",
         \"brandAmount\":\"129\",
         \"brandType\":\"乐享4G套餐\",
         \"broadBandService\":null,
         \"c3Name\":\"杭州市\",
         \"c4Id\":\"杭州市\",
         \"c4Name\":\"建德市\",
         \"c5Id\":null,
         \"c6Id\":\"101\",
         \"c6Name\":\"杭州市\",
         \"cLLI\":null,
         \"centrexGroupId\":null,
         \"centrexInnerId\":null,
         \"channelSubType\":null,
         \"channelType\":null,
         \"circuitNumber\":null,
         \"communityId\":null,
         \"communityName\":null,
         \"completedDate\":\"2016-11-22 17:07:55\",
         \"compoundProductNumber\":null,
         \"createDate\":\"2015-01-23 07:50:46\",
         \"dependentCircuitNumber\":null,
         \"effectiveEndDate\":null,
         \"effectiveStartDate\":\"2015-01-23 23:50:33.0\",
         \"emailAccount\":null,
         \"exchangeFlag\":\"N\",
         \"extOfferInstId\":null,
         \"extProdInstId\":\"99360014008**604\",
         \"faxNumber\":null,
         \"forwardFlag\":null,
         \"hqProductId\":\"235010000\",
         \"id\":\"3-6FKL153\",
         \"initiativeSuspend\":\"N\",
         \"integrationId\":\"3-6FKLULV\",
         \"integrationNum\":\"18957**60\",
         \"lastUpd\":\"2017-08-31 10:20:10\",
         \"lineNumber\":null,
         \"lossSuspendFlag\":\"N\",
         \"lteFlag\":null,
         \"mainNumberFlg\":\"Z\",
         \"managerId\":null,
         \"managerName\":null,
         \"managerPhone\":null,
         \"networkAccount\":null,
         \"networkElementType\":null,
         \"noCallFlag\":null,
         \"noRemindFlag\":null,
         \"noSuspendFlag\":null,
         \"node\":null,
         \"ocsNum\":null,
         \"peccancySuspend\":\"N\",
         \"portNum\":null,
         \"preOpenSt\":null,
         \"preOperFlag\":null,
         \"prefix\":null,
         \"productCode\":\"PHY-MAN-0022\",
         \"productId\":\"1-8GF4JTW\",
         \"productName\":\"移动电话\",
         \"promotionFlag\":\"N\",
         \"promotionId\":\"3-KV1OM1\",
         \"promotionIntegrationId\":\"3-6FKLUL8\",
         \"promotionName\":\"201407乐享4G_129元-主套餐(销售品)_ZJ\",
         \"promotionNbr\":\"5000001801100004\",
         \"purchAdjUnitPrice\":0,
         \"relatedAssetId\":null,
         \"relayMainNumber\":null,
         \"rootAssetId\":\"3-6FKL153\",
         \"rootExtProdInstId\":null,
         \"rootIntegrationId\":null,
         \"salesArea\":null,
         \"sameAddrRelationId\":null,
         \"serialNumber\":\"18957108760\",
         \"serviceAddress\":null,
         \"serviceAddressId\":null,
         \"serviceId\":\"18957****0\",
         \"serviceLength\":null,
         \"servicePointId\":null,
         \"shipToContactId\":\"3-IRNFTKU\",
         \"siGroupEndEate\":null,
         \"siGroupStartDate\":null,
         \"snNo\":null,
         \"specServiceNumber\":null,
         \"startDate\":\"2015-01-23 15:50:33\",
         \"status\":\"现行\",
         \"subAssetDtoList\":null,
         \"suspendFlag\":\"无\",
         \"userAlias\":\"方*丹\",
         \"userAliasC3Name\":null,
         \"userAliasId\":\"1-LNWRUOI\",
         \"userAliasIdType\":\"身份证\",
         \"userAliasOuNum\":null,
         \"userAliasdNumber\":\"330182198********6\",
         \"userIdentify\":\"城市\",
         \"GroupId\":null,
         \"InnerId\":null,
         \"wacGroupId\":null,
         \"wacInnerId\":null
      },
      {
         \"accountId\":\"1-LNWRUOI\",
         \"accountIdNumber\":\"330182198407010626\",
         \"accountIdType\":\"身份证\",
         \"accountManager\":null,
         \"accountManagerPhone\":null,
         \"accountName\":\"方艳丹\",
         \"accountNumber\":\"171100010758989\",
         \"addFlag\":\"Y\",
         \"addRelationId\":null,
         \"additionalFlag\":\"Y\",
         \"addr97Id\":\"337100000000000***7\",
         \"agreementId\":null,
         \"assembeServiceAddress\":\"浙江*****\",
         \"assetDescription\":null,
         \"assetExtendDescText\":\"\",
         \"assetExtendValue\":\"\",
         \"assetGrade\":null,
         \"assetPromDtoList\":null,
         \"assetXaList\":null,
         \"assurerId\":null,
         \"billAccountId\":\"3-6FKFYZX\",
         \"billAccountName\":\"方艳丹\",
         \"billAccountNum\":\"2711045***05\",
         \"billStatus\":\"计费成功\",
         \"brandAmount\":\"129\",
         \"brandType\":\"乐享4G套餐\",
         \"broadBandService\":null,
         \"c3Name\":\"杭州市\",
         \"c4Id\":\"建德市\",
         \"c4Name\":\"建德市\",
         \"c5Id\":null,
         \"c6Id\":\"5CXO\",
         \"c6Name\":\"5CXO(邓家机房72芯光配FTTH(二级分光))\",
         \"cLLI\":null,
         \"centrexGroupId\":null,
         \"centrexInnerId\":null,
         \"channelSubType\":null,
         \"channelType\":null,
         \"circuitNumber\":\"5711ASL09142550\",
         \"communityId\":null,
         \"communityName\":\"交箱501080\",
         \"completedDate\":\"2017-07-28 03:30:22\",
         \"compoundProductNumber\":null,
         \"createDate\":\"2011-02-18 04:03:21\",
         \"dependentCircuitNumber\":null,
         \"effectiveEndDate\":null,
         \"effectiveStartDate\":\"2011-02-19 04:02:25.0\",
         \"emailAccount\":null,
         \"exchangeFlag\":\"N\",
         \"extOfferInstId\":null,
         \"extProdInstId\":null,
         \"faxNumber\":null,
         \"forwardFlag\":null,
         \"hqProductId\":null,
         \"id\":\"1-LRDG6D3\",
         \"initiativeSuspend\":\"N\",
         \"integrationId\":\"1-LNWRURP\",
         \"integrationNum\":\"057101359709\",
         \"lastUpd\":\"2017-07-27 19:30:24\",
         \"lineNumber\":null,
         \"lossSuspendFlag\":\"N\",
         \"lteFlag\":null,
         \"mainNumberFlg\":null,
         \"managerId\":null,
         \"managerName\":null,
         \"managerPhone\":null,
         \"networkAccount\":\"057101359709\",
         \"networkElementType\":\"网络节点\",
         \"noCallFlag\":null,
         \"noRemindFlag\":null,
         \"noSuspendFlag\":null,
         \"node\":\"1-LNWRURP\",
         \"ocsNum\":null,
         \"peccancySuspend\":\"N\",
         \"portNum\":null,
         \"preOpenSt\":null,
         \"preOperFlag\":null,
         \"prefix\":null,
         \"productCode\":\"INT-MAN-0010\",
         \"productId\":\"1-TVGVO0S\",
         \"productName\":\"有线宽带\",
         \"promotionFlag\":null,
         \"promotionId\":\"3-KV1OM1\",
         \"promotionIntegrationId\":\"3-6FKLUL8\",
         \"promotionName\":\"201407乐享4G_129元-主套餐(销售品)_ZJ\",
         \"promotionNbr\":\"5000001801100004\",
         \"purchAdjUnitPrice\":0,
         \"relatedAssetId\":null,
         \"relayMainNumber\":null,
         \"rootAssetId\":\"1-LRDG6D3\",
         \"rootExtProdInstId\":null,
         \"rootIntegrationId\":null,
         \"salesArea\":null,
         \"sameAddrRelationId\":null,
         \"serialNumber\":null,
         \"serviceAddress\":\"浙江省杭州市,
          更楼街道甘溪村村东路17号\",
         \"serviceAddressId\":\"1-LNWRUQL\",
         \"serviceId\":null,
         \"serviceLength\":null,
         \"servicePointId\":null,
         \"shipToContactId\":\"3-IRNFTKU\",
         \"siGroupEndEate\":null,
         \"siGroupStartDate\":null,
         \"snNo\":\"5715SN90340580\",
         \"specServiceNumber\":null,
         \"startDate\":\"2011-02-18 20:02:25\",
         \"status\":\"现行\",
         \"subAssetDtoList\":null,
         \"suspendFlag\":\"无\",
         \"userAlias\":null,
         \"userAliasC3Name\":null,
         \"userAliasId\":null,
         \"userAliasIdType\":null,
         \"userAliasOuNum\":null,
         \"userAliasdNumber\":null,
         \"userIdentify\":\"城市\",
         \"GroupId\":null,
         \"InnerId\":null,
         \"wacGroupId\":null,
         \"wacInnerId\":null
      },
      {
         \"accountId\":\"1-LNWRUOI\",
         \"accountIdNumber\":\"330182198***\",
         \"accountIdType\":\"身份证\",
         \"accountManager\":null,
         \"accountManagerPhone\":null,
         \"accountName\":\"方*丹\",
         \"accountNumber\":\"171100010758989\",
         \"addFlag\":null,
         \"addRelationId\":null,
         \"additionalFlag\":null,
         \"addr97Id\":null,
         \"agreementId\":null,
         \"assembeServiceAddress\":null,
         \"assetDescription\":null,
         \"assetExtendDescText\":\"\",
         \"assetExtendValue\":\"\",
         \"assetGrade\":null,
         \"assetPromDtoList\":null,
         \"assetXaList\":null,
         \"assurerId\":null,
         \"billAccountId\":\"3-6FKFYZX\",
         \"billAccountName\":\"方*丹\",
         \"billAccountNum\":\"2711045630105\",
         \"billStatus\":\"计费成功\",
         \"brandAmount\":null,
         \"brandType\":null,
         \"broadBandService\":null,
         \"c3Name\":\"杭州市\",
         \"c4Id\":\"杭州市\",
         \"c4Name\":\"建德市\",
         \"c5Id\":null,
         \"c6Id\":null,
         \"c6Name\":null,
         \"cLLI\":null,
         \"centrexGroupId\":null,
         \"centrexInnerId\":null,
         \"channelSubType\":null,
         \"channelType\":null,
         \"circuitNumber\":\"5000001801100004-3-6FKLUL8\",
         \"communityId\":null,
         \"communityName\":null,
         \"completedDate\":\"2016-11-09 17:29:56\",
         \"compoundProductNumber\":null,
         \"createDate\":\"2015-01-23 07:51:01\",
         \"dependentCircuitNumber\":null,
         \"effectiveEndDate\":null,
         \"effectiveStartDate\":\"2015-01-22 23:50:33.0\",
         \"emailAccount\":null,
         \"exchangeFlag\":null,
         \"extOfferInstId\":\"993600140****66\",
         \"extProdInstId\":null,
         \"faxNumber\":null,
         \"forwardFlag\":null,
         \"hqProductId\":null,
         \"id\":\"3-6FKN4H5\",
         \"initiativeSuspend\":\"N\",
         \"integrationId\":\"3-6FKLUL8\",
         \"integrationNum\":\"5000001801100004-3-6FKLUL8\",
         \"lastUpd\":\"2016-11-09 09:30:31\",
         \"lineNumber\":null,
         \"lossSuspendFlag\":\"N\",
         \"lteFlag\":null,
         \"mainNumberFlg\":\"3-6FKLULV\",
         \"managerId\":null,
         \"managerName\":null,
         \"managerPhone\":null,
         \"networkAccount\":null,
         \"networkElementType\":null,
         \"noCallFlag\":null,
         \"noRemindFlag\":null,
         \"noSuspendFlag\":null,
         \"node\":null,
         \"ocsNum\":null,
         \"peccancySuspend\":\"N\",
         \"portNum\":null,
         \"preOpenSt\":null,
         \"preOperFlag\":null,
         \"prefix\":null,
         \"productCode\":null,
         \"productId\":\"3-KV1OM1\",
         \"productName\":\"201407乐享4G_129元-主套餐(销售品)_ZJ\",
         \"promotionFlag\":\"Y\",
         \"promotionId\":null,
         \"promotionIntegrationId\":null,
         \"promotionName\":null,
         \"promotionNbr\":null,
         \"purchAdjUnitPrice\":null,
         \"relatedAssetId\":null,
         \"relayMainNumber\":null,
         \"rootAssetId\":\"3-6FKN4H5\",
         \"rootExtProdInstId\":null,
         \"rootIntegrationId\":null,
         \"salesArea\":null,
         \"sameAddrRelationId\":null,
         \"serialNumber\":null,
         \"serviceAddress\":null,
         \"serviceAddressId\":null,
         \"serviceId\":null,
         \"serviceLength\":null,
         \"servicePointId\":null,
         \"shipToContactId\":null,
         \"siGroupEndEate\":null,
         \"siGroupStartDate\":null,
         \"snNo\":null,
         \"specServiceNumber\":null,
         \"startDate\":\"2015-01-22 15:50:33\",
         \"status\":\"现行\",
         \"subAssetDtoList\":null,
         \"suspendFlag\":\"无\",
         \"userAlias\":null,
         \"userAliasC3Name\":null,
         \"userAliasId\":null,
         \"userAliasIdType\":null,
         \"userAliasOuNum\":null,
         \"userAliasdNumber\":null,
         \"userIdentify\":\"城市\",
         \"GroupId\":null,
         \"InnerId\":null,
         \"wacGroupId\":null,
         \"wacInnerId\":null
      }

   ]
",
   "msghead":
   {
      "reqId":"170921092631491ILJ3x0y8",
      "result_code":"1",
      "result_msg":"查询成功"
   }

}

开始解析


Object retlistAllSubAsset=null;
try{
			retlistAllSubAsset=tmpassetQueryServict.assetQueryList(headmap,bodymap,bottommap);
													
		}catch(Exception e ){
			TPLogger.error(methodName, e);
		}
getResponseMap = aa.getResponseMap(responseObject);
		System.out.println(getResponseMap);

public Map getResponseMap(Object responseObject) {
		// TODO Auto-generated method stub
		System.out.println("AssetQueryListBean-getResponseMap-crm responseObject:"+responseObject);
		Map returnMap = new HashMap();
		Map responseObjectMap = (Map)responseObject;
		Map headMap = new HashMap();
		headMap = (Map) responseObjectMap.get("msghead");
		System.out.println("解析出的headmap:"+headMap);
		String resultCode = (String) headMap.get("result_code");
		String resultMessage = (String) headMap.get("result_msg");
		returnMap.put("RESULTCODE", resultCode);
		returnMap.put("RESULTMESSAGE", resultMessage);
		System.out.println("crmleft返回值:"+resultCode+",返回信息:"+resultMessage);
		
		String jsonMessage =(String) responseObjectMap.get("msgbody");
		JSONArray myJsonArray =new JSONArray();
		myJsonArray=JSONArray.fromObject(jsonMessage);
		//开始解析list
		if (myJsonArray!=null && myJsonArray.size()>0) {
			System.out.println("解析crm-list-map开始。。。。。。。。");
			List> salesAttributeList = new ArrayList>();
			returnMap.put("RESPONSEOBJECT", salesAttributeList);
			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
			for(int i=0;i assetItem = new HashMap();
				salesAttributeList.add(assetItem);
				Set keySet = bodyMapList.keySet();
				for(String mapKey : keySet){
					Object object = bodyMapList.get(mapKey);
					String objectString = null;
					if("integrationNum".equals((String)mapKey)){
						if (object instanceof String) {
							objectString = (String)object;
						}else if (object instanceof java.util.Date) {
							objectString = sdf.format((java.util.Date)object);
						}else {
							objectString = "";
						}
						assetItem.put(mapKey, objectString);
					}else if("productName".equals((String)mapKey)){
						if (object instanceof String) {
							objectString = (String)object;
						}else if (object instanceof java.util.Date) {
							objectString = sdf.format((java.util.Date)object);
						}else {
							objectString = "";
						}
						assetItem.put(mapKey, objectString);
					}else if("status".equals((String)mapKey)){
						if (object instanceof String) {
							objectString = (String)object;
						}else if (object instanceof java.util.Date) {
							objectString = sdf.format((java.util.Date)object);
						}else {
							objectString = "";
						}
						assetItem.put(mapKey, objectString);
					}
					
				}
				System.out.println("解析出的list_map-crm:"+bodyMapList);
			}
		}
		
		
		System.out.println("AssetQueryListBean-getResponseMap-crm return :"+responseObjectMap);
		return returnMap;
	}


















你可能感兴趣的:(java)