boostorg / json

A C++11 library for parsing and serializing JSON to and from a DOM container in memory.
https://boost.org/libs/json
Boost Software License 1.0
434 stars 97 forks source link

Direct serialization #1046

Open kelbon opened 1 month ago

kelbon commented 1 month ago

Do library provide interface to serialize structs into json string without creating a json value? As i see, serialization requires json value

grisumbras commented 1 month ago

Direct serialization will be released with Boost 1.87.

kelbon commented 1 month ago

what interface it will provide?

grisumbras commented 1 month ago

Basically the same as with value serialization. https://www.boost.org/doc/libs/develop/libs/json/doc/html/json/ref/boost__json__serialize/overload5.html

kelbon commented 1 month ago

So it will work with boost pfr/ boost describe struct or what? I need more low lower level interface with serializing strings/ints/keys etc

kelbon commented 1 month ago

Such interface witih returning string will not match with output iterators, (for not copying string after it created), also i think such overload serialize(auto& value, options) may break many overloads in current code

grisumbras commented 1 month ago

I can assure you that we have tests for this, no overload ambiguity happens.

If you want something more granular, setializer also will support direct operation. https://www.boost.org/doc/libs/develop/libs/json/doc/html/json/ref/boost__json__serializer/reset/overload5.html