我在使用JSONConvert
解析下面的JSON时遇到异常{'d':{
'results': [
{
'__metadata': {
'id': 'a4ddaefa-8014-450e-84ff-dada399707',
'uri': 'https://some.server.com/_api/Web/Lists(**GUID**'aaaa-bbbb-cccc-b7b0-eeeee')/Items(1)',
'etag': '\'1\'',
'type': 'SP.Data.TestListItem'
},
'Title': 'sadfsdf'
}
]
}
}
GUID后字符的抛出错误。
感谢任何帮助或指示
答案 0 :(得分:2)
您需要使用双引号而不是单引号:
{
"d": {
"results": [
{
"__metadata": {
"id": "a4ddaefa-8014-450e-84ff-dada399707",
"uri": "https: //some.server.com/_api/Web/Lists(**GUID**'aaaa-bbbb-cccc-b7b0-eeeee')/Items(1)",
"etag": "'1'",
"type": "SP.Data.TestListItem"
},
"Title": "sadfsdf"
}
]
}
}
或格式化压缩:
{\"d\":{\"results\":[{\"__metadata\":{\"id\":\"a4ddaefa-8014-450e-84ff-dada399707\",\"uri\":\"https: \/\/some.server.com\/_api\/Web\/Lists(**GUID**\'aaaa-bbbb-cccc-b7b0-eeeee\')\/Items(1)\",\"etag\":\"\'1\'\",\"type\":\"SP.Data.TestListItem\"},\"Title\":\"sadfsdf\"}]}}
答案 1 :(得分:0)
这在jsonlint.com中有效。除了uri之外,将单引号更改为double。
{
"d": {
"results": [
{
"__metadata": {
"id": "a4ddaefa-8014-450e-84ff-dada399707",
"uri": "https: //some.server.com/_api/Web/Lists(**GUID**'aaaa-bbbb-cccc-b7b0-eeeee')/Items(1)",
"etag": "\"1\"",
"type": "SP.Data.TestListItem"
},
"Title": "sadfsdf"
}
]
}
}