package com.xx.logPlayBack.xx.utils;
public class jsonToGet {
public static void main(String[] args) {
// 从数据库读取的日志如下,测试Demo""转义为''
String strJson = "{'appScene':'new','systemInfo':'{'version':'8.4.2','type':'2,3,5,7'}}";
// { }分别转义为空 " '分别转义为空 :转义为= ,转义为&
String strGet = strJson.replace("{", "").replace("}", "").
replace("\"", "").replace("'", "").
replace(":", "=").replace(",", "&");
System.out.println("======转义前的strJson请求为======" + strJson);
System.out.println("======转义后的strGet请求为======" + strGet);
String jsonRequest = "{\"appScene\":\"mobile_multi\",\"system_info\":\"{\\\"ver\\\":\\\"8.5.2\\\",\\\"os\\\":\\\"Android\\\"}";
String getRequest = jsonRequest.replace("{", "").replace("}", "").
replace("\"", "").replace("'", "").
replace(":", "=").replace(",", "&");
System.out.println("======转义前的jsonRequest请求为======" + jsonRequest);
System.out.println("======转义后的getRequest请求为======" + getRequest);
}
}
运行结果:
待续。。。