Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我从外部 json 源获取数据,如下所示
{"root":{"name":"Haf"eez","skills":["java","j2ee","jquery","ext-js"]}}
如何在java中解析这个。Hafeez 这个词的中心有双引号。
逃脱上述后,我会做
jsonObject = new JSONObject(new JSONTokener( new InputStreamReader(input)));
使用反斜杠转义。用。。。来代替 \\”
使用正则表达式:str.replaceAll("([a-zA-Z0-9])(\")([a-zA-Z0-9])", "$1\\\\\\\\\"$3");
str.replaceAll("([a-zA-Z0-9])(\")([a-zA-Z0-9])", "$1\\\\\\\\\"$3");