如何识别一个字符串是不是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"}]}
6、转义空格、换行、回车
{"a":\r\n"d"}
标签:嵌套,test,json,数组,带有,字符串,格式,null 来源: https://www.cnblogs.com/yulia/p/14074070.html