hjson / hjson-js

Hjson for JavaScript
https://hjson.github.io/
MIT License
417 stars 49 forks source link

How do I use options? #22

Closed tmamedbekov closed 7 years ago

tmamedbekov commented 7 years ago

Can you please explain how to use options on var text2 = Hjson.stringify(obj); after everything is being parsed I would like to add quotes to all my original json strings.

var obj = Hjson.parse(output); var text2 = Hjson.stringify(obj);

after this is being done, I get a stripped down code.

laktak commented 7 years ago

See the docs here.

For example var text2 = Hjson.stringify(obj, { quotes: "strings" });

tmamedbekov commented 7 years ago

yeap yeap already got it going. var text2 = Hjson.stringify(obj, {keepWsc: false, bracesSameLine: true, quotes: "strings", quotes: "keys", separator: true});

online tool is really cool. it is not that easy to set it up in Node application. finally figured it out.

laktak commented 7 years ago

You can only specify one value for quotes - you probably want quotes: "all"

What is not easy to set up? Would a sample help? (it's actually here but not mentioned in the README).

tmamedbekov commented 7 years ago

That actual string worked for me. I got confused actually with the options. Maybe you could add same sample code to the GH page. Thanks anyways really great tool, helped do a major thing :)