How to convert a json response into yaml in bash

后端 未结 6 1821
不知归路
不知归路 2020-12-31 11:04

I read data from a json file with jq. I wanna append the results into a yaml file, but I dont get it working. I am quite new to shell programming. My goal is to append that

6条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-31 11:45

    I've used ruby to write my json content into yaml.

    As for your example, it can be achieved like this:

    cat $DEFAULTS_FILE | jq .users | ruby -ryaml -rjson -e 'puts YAML.dump(JSON.parse(STDIN.read))' > my.yml
    

提交回复
热议问题