I want to use jq
to format a JSON file in Windows. So far, I haven't been able to find a way to perform this task using a single jq
command.
Thus, I wrote this batch file:
rem create formatted JSON output file
jq-win64.exe . "%1" >"temp.tmp"
rem replace the unformatted JSON input file with the formatted JSON output file
del "%1"
ren "temp.tmp" "%1"
Is there a way to instruct jq
to do this without performing these gymnastics?
You want the following:
jq . "%1" >"%1".tmp
if not errorlevel 1 move /y "%1".tmp "%1" >nul
jq
has no option to do this for you.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.