gpt4 book ai didi

jquery - JSON 中的意外标记 {

转载 作者:数据小太阳 更新时间:2023-10-29 03:34:35 27 4
gpt4 key购买 nike

你好,我正在使用 Elastic Search 和 Golang,当我使用 Golang 的 Json Encoder 函数将数据发送到 jquery 时,在 Golang 中从 Elasticsearch 索引获取数据后,我得到 “Unexpected token { in JSON " 在 jquery 中解析数据时出错

这是 Goland Json 编码器发送给 Jquery 的内容:

{"id":212,"user_id":10,"meta_description":"Plot,G-16, Islamabad,In G-16, Islamabad, Islamabad","property_type":"16","Location1":"Pakistan","Location2":"Islamabad","Location3":null,"Location4":"Islamabad","price":1850000,"bedrooms":0,"bathrooms":0,"add_date":{"Time":"0001-01-01T00:00:00Z","Valid":false}}
{"id":213,"user_id":10,"meta_description":"Plot,G-16, Islamabad,In G-16, Islamabad, Islamabad","property_type":"16","Location1":"Pakistan","Location2":"Islamabad","Location3":null,"Location4":"Islamabad","price":1800000,"bedrooms":0,"bathrooms":0,"add_date":{"Time":"0001-01-01T00:00:00Z","Valid":false}}

最佳答案

您的 JSON 数据缺少两件重要的事情,一件是将其封装在方括号中,并为每个数据使用 ',' 作为分隔符。或多或少应该是这样的:

[{
"id": 212,
"user_id": 10,
"meta_description": "Plot,G-16, Islamabad,In G-16, Islamabad, Islamabad",
"property_type": "16",
"Location1": "Pakistan",
"Location2": "Islamabad",
"Location3": null,
"Location4": "Islamabad",
"price": 1850000,
"bedrooms": 0,
"bathrooms": 0,
"add_date": {
"Time": "0001-01-01T00:00:00Z",
"Valid": false
}
}, {
"id": 213,
"user_id": 10,
"meta_description": "Plot,G-16, Islamabad,In G-16, Islamabad, Islamabad",
"property_type": "16",
"Location1": "Pakistan",
"Location2": "Islamabad",
"Location3": null,
"Location4": "Islamabad",
"price": 1800000,
"bedrooms": 0,
"bathrooms": 0,
"add_date": {
"Time": "0001-01-01T00:00:00Z",
"Valid": false
}
}]

我做了很小的更改,如果您不确定数据,最好的选择是尝试在此处验证它:https://jsonlint.com/

关于jquery - JSON 中的意外标记 {,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50404248/

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