import com.alibaba.fastjson.JSONObject;
public class Demo {
public static void main(String[] args) {
JSONObject json = new JSONObject();
json.put("key", "content\tvalue");
System.out.println(json.get("key"));
// result:content value
}
}
\t should not be converted to a tab. Tabs are not allowed inside strings.
The JSON Data Interchange Syntax says: Insignificant whitespace is allowed before or after any token. Whitespace is any sequence of one or more of the following code points: character tabulation (U+0009), line feed (U+000A), carriage return (U+000D), and space (U+0020). Whitespace is not allowed within any token, except that space is allowed in strings.
4条答案
按热度按时间tpgth1q71#
个人觉得这个地方也没有必要转义,也不会去转义
f5emj3cl2#
刚刚试了一下可以啊,
\t
转成制表符了tvz2xvvm3#
\t
should not be converted to a tab. Tabs are not allowed inside strings.The JSON Data Interchange Syntax says: Insignificant whitespace is allowed before or after any token. Whitespace is any sequence of one or more of the following code points: character tabulation (U+0009), line feed (U+000A), carriage return (U+000D), and space (U+0020). Whitespace is not allowed within any token, except that space is allowed in strings.
vawmfj5a4#
This issue has been fixed and can be closed. It's escaping tabs correctly
Tested both
\t
and\u0009
on version1.2.75