I wanted to save the contents of an array to a .json file.The array has some dictionaries in it. I tried
Set-Content -Path 'crl_urls.json' -Value $arrayval -Force
The JSON file has stored System.Collections.Hashtable
. It hasn't stored the values of the dictionaries.
So How do I do it?
To correctly save the content in a .json file you should first convert the array to the .json format. Try this:
ConvertTo-Json -InputObject $arrayval | Out-File -FilePath .\crl_urls.json
By using the ConvertTo-Json
cmdlet I was able to export the contents of the array in the JSON file. Example Code:
Set-Content -Path 'crl_urls1.json' -Value ($arrayval|ConvertTo-Json) -Force
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.