Closed MartinMuzatko closed 6 years ago
If I understand you correctly you should be able to do this with
hjson -c < input.hjson | jq [...] | hjson > output.hjson
where you replace [...]
with the commands to edit your json.
Thanks for the reply. Unfortunately, this will not keep my comments and this will only put the selected properties as raw text. What I need, is to change only one property and write it back with the full hjson file while keeping comments.
So
{
// some comments
test: "my test"
numbers: 34938
}
can be turned into
{
// some comments
test: "my test is complete"
numbers: 34938
}
It looks like I have to workaround this with sed
:/
Would this help?
node -e 'var Hjson=require("hjson"), fs=require("fs"); var data=Hjson.rt.parse(fs.readFileSync("test.hjson", "utf8")); data.foo="bar"; console.log(Hjson.rt.stringify(data));'
You need to npm i hjson
first or require it from npm's global folder.
This is sort of what I'm doing as of now. Having this built into hjson would be nice. I will share my implementation next year. Thank you so far :)
Hello! I'm using
hjson
in combination withjq
to read from hjson on the commandline. See https://jqplay.org/s/pD2ADtE_rnI would like to be able to write to hjson file via terminal. Right now this is not possible.
Suggested syntax:
Let me know what you think!