How to parse a json file into variables using windows command line?

I have this JSON file called test.json that states:

 { "test":true, "limit": { "min":0.5, "max":1.5 } } 

I would like to read this file on the Windows command line and parse these objects as variables.

How can I do it?

+7
json command-line windows
source share
1 answer

If you use Windows Powershell as a command line, you can use the ConvertFrom-JSON cmdlet: http://powershelljson.codeplex.com/

Make sure PowerShell version is higher than 3.0, because ConvertFrom-JSON is available from this version .

If you are using a plain old CMD, you will need an external tool for it. I like jq: http://stedolan.imtqy.com/jq/ . The tutorial uses curl for examples, but you can just as easily use echo or read JSON from a file.

+5
source share

All Articles