How do you parse a simple JSON string in Batch?
For example, if I have the following JSON string:
{ \"...\":\"...\", \"year\": 2016, \"time\": \"05:01\
There are different ways, here's one.
@echo off
set string={ "year": 2016, "time": "05:01" }
set string=%string:"=%
for /f "tokens=3,5" %%a in ('echo %string%') do set d=%%a&set t=%%b
echo -%d%- -%t%-
pause & goto :EOF
and here's a second:
@echo off
set string={ "year": 2016, "time": "05:01" }
for /f "tokens=3,5" %%a in ('echo %string%') do set d=%%~a&set t=%%~b
echo -%d%- -%t%-
pause & goto :EOF