JSON处理 格式化json
⎯⎯ 不必行色匆匆,不必光芒四射,不必成为别人,只需做自己。下午好。

格式化json

 842  |   | 


转义:    
         
说 明

格式化json



功能介绍

1.对待格式化的 json 串进行格式化/压缩, 同时支持转义
2.支持对字符串包含的 json 串进行转义
3.对格式错误的会提示在什么位有错误



示例


1.正确格式的

{"name":"test","age":10,"addr":"四川成都","cls_info":[{"name":"篮球班","teacher":"张老师"},{"name":"美术班","teacher":"李老师"}]}

处理后

{
 "name": "test",
 "age": 10,
 "addr": "四川成都",
 "cls_info": [
  {
   "name": "篮球班",
   "teacher": "张老师"
  },
  {
   "name": "美术班",
   "teacher": "李老师"
  }
 ]
}

2.错误的格式

{"name":"test","age":10,"addr":"四川成都""cls_info":[{"name":"篮球班","teacher":"张老师"},{"name":"美术班","teacher":"李老师"}]}

处理后

错误如下:

川成都"XXX"cls_info":[{"

XXX附近有错误, 确认是否符号缺少或多余

说明: 错误出现在 XXX 附近, 建议进行搜索查看


3.包含json串

name=test&age=12&other={"name":"test","age":10,"addr":"四川成都","cls_info":[{"name":"篮球班","teacher":"张老师"},{"name":"美术班","teacher":"李老师"}]}

处理后

name=test&age=12&other={
 "name": "test",
 "age": 10,
 "addr": "四川成都",
 "cls_info": [
  {
   "name": "篮球班",
   "teacher": "张老师"
  },
  {
   "name": "美术班",
   "teacher": "李老师"
  }
 ]
}