0

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?

2 Answers 2

2

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
Sign up to request clarification or add additional context in comments.

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.