Map<String, String> map =dataSnapshot.getValue(Map.class);
String MR_ID = map.get("MR_ID");
String JOB_TITLE = map.get("JOB_TITLE");
String JOB_TYPE = map.get("JOB_TYPE");
String Delv_ADDR=map.get("Delv_ADDR");
DataSnapshot {key = platformdb,value = {MR_RELATIONS = {CUSTOMERS = {ORDERS = {INVENTORY =,Delv_ADDR = D-103 LaxmiNagar New Delhi,ORDER_ID =}}},MR_SCHEDULE = {MR_ID =,JOB_TITLE =, GEO_LINK =,JOB_TYPE = {TSP = {TSP_ADDR =,TSP_ID =,GEO_LINK =,TSP_NAME =}, SCC = {SCC_ID =,SCC_ADDR =,GEO_LINK =,SCC_NAME =},CUSTOMER = {GEO_LINK =, CUST_NAME =,CUST_ID =,CUST_ADDR =}},JOB_ID =,TRANS_SRC =,TRANS_DEST =}, MR_POOL = {FREE_MR =,BUSY_MR = {77889992222 = {IS_BUSY = false, GEO_LINK = 8yyttrd}}}}}
这是我的数据我在地图中我想要解析并获得 Delv_ADDR 的值但是我无法得到我得到空值请建议我如何获取该数据< / p>
答案 0 :(得分:0)
在附加的输入中,似乎地图中只有一个条目,其中键为platformdb
,值为MR_RELATIONS=...
。
如果您正在执行String MR_ID = map.get("MR_ID");
,那么它可能会返回null
,因为地图中没有带有键MR_ID
的条目。
您应该做的是通过执行以下操作来检索密钥的值:
String response = map.get("platformdb");
然后解析此响应String以提取所需的值。
因为,响应似乎不是JSON,您可以尝试使用本机String函数。
例如,要从响应中提取MR_ID
,您可以执行以下操作:
String response = map.get("platformdb");
String MR_ID = response.substring(response.indexOf("MR_ID=") + 6,
response.indexOf("MR_ID=") + response.indexOf(","));
String Delv_ADDR = response.substring(response.indexOf("Delv_ADDR=") + 10,
response.indexOf("Delv_ADDR=") + response.indexOf(","));