I have the following json input file( I know it's not a good structure, but I cannot change it)
{
"TEST1": {
"ONE": "value",
"TWO": "value-1",
},
"TEST2": [
{
"A": [
"test": "test"
],
"B-B":[
"test": "test"
]
}
]
}
And I want to process it in batch loop. But sometimes there are special characters inside which needs to be escaped.
for /f %%i in ('type %LOCAL_PATH_FILE% ^| %JQ% -r ".TEST2[] | keys[]"') do (
set SUB=%%i
ECHO sub is !SUB!
for /f %%j in ('type %LOCAL_PATH_FILE% ^| %JQ% -r ".TEST2[].!SUB![] | keys[]"') do (
set CONTENT=%%j
ECHO content path is !CONTENT!
)
)
The current result looks like:
jq: error: syntax error, unexpected IDENT, expecting $end (Windows cmd shell quoting issues?) at <top-level>, line 1:
.TEST2[].B-B[] | keys[]
jq: 1 compile error
The process tried to write to a nonexistent pipe.
I know it should somehow possible to escape it via quota, but I'm not able to find the correct syntax for it.
Maybe someone can help me :)