jeaye/jeayeson

Formatting output?

lukkio88 opened this issue · 1 comments

Hi,

Is it possible to get a formatted output with some indentation?
I've tried to dump a json file, but it gets dumped in a single line, which isn't readable.

jeaye commented

Hi! That wasn't built into jeayeson, since it was more focused on showing how templates can be used instead of macros to create a nice JSON API.

I highly recommend using jq, if you have a bash command line. You can pretty print a file like so:

$ jq '.' < my-file.json

You can also pretty print the output of a command (like your program built with jeayeson) like so:

$ my-program | jq '.'

Alternatively, in your browser, you can use https://jsonlint.com/ or similar.

If you absolutely need your JSON lib to do this, you can either add it into detail/stream.hpp or (more likely) pick another modern C++ JSON lib.

Happy hacking. 😃