gpt4 book ai didi

json - ConvertFrom-Json : Cannot convert the JSON string because a dictionary that was converted from the string contains the duplicated keys

转载 作者:行者123 更新时间:2023-12-04 21:57:48 31 4
gpt4 key购买 nike

从 OData API 服务返回以下 JSON:

{
"d": {
"results": [
{
"FileSystemObjectType": 0,
"Id": 1,
"ContentTypeId": "0x0100BC97B2F575CB0C42B79549F3BABD32A8",
"Title": "Nokia California",
"Address": "200 South Matilda Avenue\nW Washington Ave\n94086 Sunnyvale, California\nUnited States of America",
"ID": 1,
"Modified": "2014-02-24T10:06:39Z",
"Created": "2014-02-24T10:06:39Z",
"AuthorId": 12,
"EditorId": 12,
"OData__UIVersionString": "1.0",
"Attachments": false,
"GUID": "d12aafad-502a-4968-a69e-36a7ea05ec80"
}
]
}
}

并以字符串形式保存到名为 $data 的变量中

尝试使用 ConvertFrom-Json 将 JSON 格式的字符串转换为自定义对象小命令:
$results = $data | ConvertFrom-Json

给出以下错误:

ConvertFrom-Json : Cannot convert the JSON string because a dictionary that was converted from the string contains the duplicated keys 'Id' and 'ID'.



有没有办法在 PowerShell 中转换指定的 JSON 格式的字符串?

最佳答案

这是我如何处理它:

$results = $data.ToString().Replace("ID", "_ID") | ConvertFrom-Json

关于json - ConvertFrom-Json : Cannot convert the JSON string because a dictionary that was converted from the string contains the duplicated keys,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22080350/

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