json icon indicating copy to clipboard operation
json copied to clipboard

Indented serialisation

Open infn-ke opened this issue 3 years ago • 4 comments

Can the output from value_from be indented to make reading output easier?

std::cout << boost::json::value_from( b ) << std::endl;

infn-ke avatar Nov 18 '22 17:11 infn-ke

value_from doesn't output anything, it creates a value container. You essentially ask for indented serialisation. It won't be possible with operator<<, but we will think about implementing it for serialize.

grisumbras avatar Nov 18 '22 17:11 grisumbras

Meanwhile, here's an example of how to do it manually https://www.boost.org/doc/libs/1_80_0/libs/json/doc/html/json/examples.html

grisumbras avatar Nov 18 '22 17:11 grisumbras

value_from doesn't output anything, it creates a value container. You essentially ask for indented serialisation. It won't be possible with operator<<, but we will think about implementing it for serialize.

I took value_from from the docs, that is not working?

https://www.boost.org/doc/libs/develop/libs/describe/doc/html/describe.html#example_to_json

Is there a better way converting from structs to json?

infn-ke avatar Nov 18 '22 21:11 infn-ke

No, why are you asking?

grisumbras avatar Nov 19 '22 11:11 grisumbras