Skip to content

Instantly share code, notes, and snippets.

@TriHydera
Forked from navono/jsonParser.bat
Created April 9, 2022 18:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TriHydera/ee0c0ba0122543908473f027a42cac8a to your computer and use it in GitHub Desktop.
Save TriHydera/ee0c0ba0122543908473f027a42cac8a to your computer and use it in GitHub Desktop.
parse JSON file by windows batch
:: Read file "package.json" into variable string, removing line breaks.
set string=
for /f "delims=" %%x in (package.json) do set "string=!string!%%x"
rem Remove quotes
set string=%string:"=%
rem Remove braces
set "string=%string:~2,-2%"
rem Change colon+space by equal-sign
set "string=%string:: ==%"
rem Separate parts at comma into individual assignments
set "%string:, =" & set "%"
echo %version%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment