gpt4 book ai didi

javascript - 这个 JSON 字符串有什么问题?它还可以与 JSONLint 一起使用

转载 作者:行者123 更新时间:2023-12-02 14:45:12 29 4
gpt4 key购买 nike

这个 JSON 字符串似乎无效,但是当我使用 JSONLint 检查它时,它说它有效,那么问题出在哪里。在位置252处弹出错误。

let test = JSON.parse('[{"id":6,"item_type":"cybro_unit","unitId":6,"pos_id":9,"name":"CyBro-2","image":"images/cybro/defaultBro.png","layer":"10","positionX":111.0,"positionY":249.0,"layerName":"10","sizeX":201.0,"sizeY":168.0,"z_index":9999,"showLabel":true,"hint":"CyBro-2\nPovezan: true\nVelikost X: 201.523163\nVelikost Y: 168.675491","enabled":true,"connected":false}]');

[{
"id": 6,
"item_type": "cybro_unit",
"unitId": 6,
"pos_id": 9,
"name": "CyBro-2",
"image": "images/cybro/defaultBro.png",
"layer": "10",
"positionX": 111.0,
"positionY": 249.0,
"layerName": "10",
"sizeX": 201.0,
"sizeY": 168.0,
"z_index": 9999,
"showLabel": true,
"hint": "CyBro-2\nPovezan: true\nVelikost X: 201.523163\nVelikost Y: 168.675491", // here at CyBro-2
"enabled": true,
"connected": false
}]

最佳答案

很可能是转义字符,伙计,您是否尝试过转义\,因此无论您做什么都不会将其检测为换行符?

编辑:

我的意思是我刚刚做到了并且成功了,试试这个:

JSON.parse('[{"id":6,"item_type":"cybro_unit","unitId":6,"pos_id":9,"name":"CyBro-2","image":"images/cybro/defaultBro.png","layer":"10","positionX":111.0,"positionY":249.0,"layerName":"10","sizeX":201.0,"sizeY":168.0,"z_index":9999,"showLabel":true,"hint":"CyBro-2\\nPovezan: true\\nVelikost X: 201.523163\\nVelikost Y: 168.675491","enabled":true,"connected":false}]');

关于javascript - 这个 JSON 字符串有什么问题?它还可以与 JSONLint 一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55276124/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com