Parse and store text from a json file in windows b

2020-07-22 09:52发布

问题:

I have a json file with the following contents

{"STATUS":"PASS","PASSRATE":96.95238}

I want to store the passrate so that I can use it to append to a filename.

回答1:

Check jsonextractor.bat with which you can extract information from json file by given dot notated path to object:

jsonextractor.bat data.json PASSRATE


回答2:

You could use Xidel for that:

xidel -s data.json -e "$json/PASSRATE"