1

我使用“调用请求”来获取下面的 JSON。我想将其转换为多维数组。我在网上查了,但找不到合适的解决方案。答案会很好,如果不是,那么向我指出适当的资源也会有所帮助。

谢谢

{"ResultForName":
    [{"Name":"work","Values":["no"]},
    {"Name":"location","Values":["\\pc\\documents"]},
    {"Name":"Authority","Values":["10"]},
    {"Name":"City","Values":["Toronto"]},
    {"Name":"Country","Values":["CA"]},
    {"Name":"Created By","Values":["George"]},
    {"Name":"Money Vault Id","Values":["100000"]},
    {"Name":"Opened  On","Values":["Mark, John, L=Toronto, S=Ontario, C=CA","www.doman.com", O=Office, L=Toronto, S=Ontario, C="CA"]},
                    {"Name":"Driver Name","Values":["Honda"]},
                    {"Name":"Can drive","Values":["0"]},
                    {"Name":"Given Name","Values":["Steven"]},
                    {"Name":"Group Id","Values":["34324"]},
                    {"Name":"Internet System Address","Values"["www.doman.com/Locations"]},
                    {"Name":"Key value","Values":["AXU"]},
                    {"Name":"Key Encryption","Values":["128"]},
                    {"Name":"Last Check up","Values":["12\/20\/2018 04:00:08"]},
                    {"Name":"Last Notification","Values":["11\/22\/2018 05:00:59"]},
                    {"Name":"Last used by","Values":["David"]},
                    {"Name":"Last Used On","Values":["09\/11\/2018 14:57:50"]},
                    {"Name":"Validation","Values":["02\/22\/2019 04:06:18"]},
                    {"Name":"Last Validation query","Values":["Success"]},
                    {"Name":"Last Acceptence","Values":["04\/12\/2019 04:10:11"]},
                    {"Name":"Managed By","Values":["Manager"]},
                    {"Name":"Automatic","Values":["True"]},
                    {"Name":"Options","Values":["More options Needed"]},
                    {"Name":"Organization","Values":["Organization"]},
                    {"Name":"Organizational Unit","Values":["CSV"]},
                    {"Name":"Work Location Date","Values":["02\/29\/2019 02:00:40"]},
                    {"Name":"URL Details","Values":["CN=web.website.com,O=\"Organization\",OU=CSV,L=Toronto,ST=Ontario,C=CA"]},
                    {"Name":"Provence","Values":["Ontario"]},
                    {"Name":"Surname","Values":["Johnson"]},
                    {"Name":"Transaction value","Values":["23452523"]},
                    {"Name":"Validation Acceptance Values",
                                    "Values":["111.11.11.11|443|0|11|0|organization.com\\3$","111.11.111.111|443|0|11|0|orgaization.com\\2$","111.11.111.111|443|0|11|0|orgaization.com\\2$"]},
                    {"Name":"Acceptance  State","Values":["Success"]},
                    {"Name":"Validity Zone","Values":["120"]},
                    {"Name":"ClearMode","Values":["0"]},
                    {"Name":"Approval CA:Count","Values":["1"]},
                    {"Name":"Reader","Values":["Office"]},
                    {"Name":"End Date","Values":[""]},
                    {"Name":"Meeting Subject","Values":["adb.organization.com"]},
                    {"Name":"SubjectAltName DNS","Values":["adb.organization.com","ade.organization.com","Create.orgaization.com"]}],
"Result":1}
4

1 回答 1

0

JSON中有两个问题行:

  • 这条线有一个错位"

{"Name":"Opened On","Values":["Mark, John, L=Toronto, S=Ontario, C=CA","www.doman.com", O=Office, L=Toronto, S=Ontario, C="CA"]},

应该是

{"Name":"Opened On","Values":["Mark, John, L=Toronto, S=Ontario, C=CA","www.doman.com", "O=Office, L=Toronto, S=Ontario, C=CA"]},

  • 而这条线

{"Name":"Internet System Address","Values"["www.doman.com/Locations"]},

应该有一个:“价值观”之后

{"Name":"Internet System Address","Values":["www.doman.com/Locations"]},

一旦你解决了这些问题,结果就是有效的 JSON 并且可以通过管道传输到 ConvertFrom-JSON:

$JSON = @"
{"ResultForName":
    [{"Name":"work","Values":["no"]},
    {"Name":"location","Values":["\\pc\\documents"]},
    {"Name":"Authority","Values":["10"]},
    {"Name":"City","Values":["Toronto"]},
    {"Name":"Country","Values":["CA"]},
    {"Name":"Created By","Values":["George"]},
    {"Name":"Money Vault Id","Values":["100000"]},
    {"Name":"Opened  On","Values":["Mark, John, L=Toronto, S=Ontario, C=CA","www.doman.com", "O=Office, L=Toronto, S=Ontario, C=CA"]},
    {"Name":"Driver Name","Values":["Honda"]},
    {"Name":"Can drive","Values":["0"]},
    {"Name":"Given Name","Values":["Steven"]},
    {"Name":"Group Id","Values":["34324"]},
    {"Name":"Internet System Address","Values":["www.doman.com/Locations"]},
    {"Name":"Key value","Values":["AXU"]},
    {"Name":"Key Encryption","Values":["128"]},
    {"Name":"Last Check up","Values":["12\/20\/2018 04:00:08"]},
    {"Name":"Last Notification","Values":["11\/22\/2018 05:00:59"]},
    {"Name":"Last used by","Values":["David"]},
    {"Name":"Last Used On","Values":["09\/11\/2018 14:57:50"]},
    {"Name":"Validation","Values":["02\/22\/2019 04:06:18"]},
    {"Name":"Last Validation query","Values":["Success"]},
    {"Name":"Last Acceptence","Values":["04\/12\/2019 04:10:11"]},
    {"Name":"Managed By","Values":["Manager"]},
    {"Name":"Automatic","Values":["True"]},
    {"Name":"Options","Values":["More options Needed"]},
    {"Name":"Organization","Values":["Organization"]},
    {"Name":"Organizational Unit","Values":["CSV"]},
    {"Name":"Work Location Date","Values":["02\/29\/2019 02:00:40"]},
    {"Name":"URL Details","Values":["CN=web.website.com,O=\"Organization\",OU=CSV,L=Toronto,ST=Ontario,C=CA"]},
    {"Name":"Provence","Values":["Ontario"]},
    {"Name":"Surname","Values":["Johnson"]},
    {"Name":"Transaction value","Values":["23452523"]},
    {"Name":"Validation Acceptance Values",
                    "Values":["111.11.11.11|443|0|11|0|organization.com\\3$","111.11.111.111|443|0|11|0|orgaization.com\\2$","111.11.111.111|443|0|11|0|orgaization.com\\2$"]},
    {"Name":"Acceptance  State","Values":["Success"]},
    {"Name":"Validity Zone","Values":["120"]},
    {"Name":"ClearMode","Values":["0"]},
    {"Name":"Approval CA:Count","Values":["1"]},
    {"Name":"Reader","Values":["Office"]},
    {"Name":"End Date","Values":[""]},
    {"Name":"Meeting Subject","Values":["adb.organization.com"]},
    {"Name":"SubjectAltName DNS","Values":["adb.organization.com","ade.organization.com","Create.orgaization.com"]}],
"Result":1}
"@
$JSON | ConvertFrom-Json
于 2019-05-29T22:45:57.977 回答