如何识别一个字符串是不是json格式
1、简单
{}
{"a":null}
{"a":1}
{"a":"test"}
{"a":1,"b":"test"}
2、带有数组
{"a":["1","2"]}
{"b":[1,2]}
3、带有json数组
{"a":[{"b":1,"c":"2"},{"d":null,"f":"2"}]}
4、数组嵌套\json嵌套
{"a":[{"b":1,"c":"2","d":[{"a":1},{"b":"c"}]},{"d":null,"f":"2"}]}
{"a":[{"b":1,"c":"2","d":[{"a":1},{"b":"c"},[{"a":1},{"b":"c"}]]},{"d":null,"f":"2"}]}
{"a":[{"b":1,"c":"2","d":[{"a":1},[{"a":1},{"b":"c"},[{"a":1},{"b":"c"},[{"a":1},{"b":"c"}]]]]},{"d":null,"f":"2"}]}
6、转义空格、换行、回车
{"a":\r\n"d"}