转化为json
Map<String, Object> data;
JSONObject dataJson = new JSONObject(data);//map转化为json
String cano= (“CarNO”);
转化为json
eg1
String results= (params,type);
(“*********results:”+results);
JSONObject dataJson = new JSONObject();//注意这里的JSONObject为
/* dataJson = new ();*/
JSONObject er= (JSONObject) (results);//String转化为json
success= ((“success”).toString()) ;
eg2
String results = (());
JsonObject json=new JsonParser().parse(results).getAsJsonObject();
int resultCode=(“resultCode”).getAsInt();
(“querypersonsbycar-SUCCESS:获取人员卡信息成功没有信息时的数据! 信息如下:”+json);
if(resultCode==0){
JsonElement dataItems=(“dataItems”);
转为Map,Map转为json:
results = (orderno, “Weixin”, null, “蜜服务测试”, 1, null, null, 1, null, null, null,
“测试”, null, “691152”, “”, “”, null, “wxc992e3bd110b5b87”, openid);
Map mihelpmap = (results);//String转Map
dataJson = new (mihelpmap );//map转json
①//String转map
import ;
String str=“”;
HashMap hashMap = (str, );
②
map转string
String paramMap= (map);
③
JSONObject jsont=(paramMap);