I have a .json file and want to extract the value for a certain key - but the key occurs multiple times (because the JSON contains a list of arrays). But I know that the value I am looking for starts with a certain prefix, so I wrote this:
for /f "tokens=1,2 delims=:, " %%a in (' find ":" ^< "myjson.json" ') do (
    if "%%~a"=="mykey" (
        set VALUE_I_WANT_TO_EXTRACT=%%~b
        echo b: %%~b
        echo var: %VALUE_I_WANT_TO_EXTRACT%
        IF "%VALUE_I_WANT_TO_EXTRACT:~0,8%"=="myprefix" (
            goto leave
        )
    )
)
:leave
prints:
b: myprefixvalue
var:
b: othervalue1
var: 
b: othervalue2
var:
When I REM out the line echo b: %%~b I get:
var: othervalue2
var: othervalue2
var: othervalue2
What happens here? And how do I get the value I am looking for?