【店小二】公告:

格式化json
6641  |   |   |  58

功能介紹

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": "李老師"
        }
    ]
}