dropbox / json11

A tiny JSON library for C++11.
MIT License
2.55k stars 616 forks source link

No API to add Json (f.e. array) to Json::object outside of ctor. #147

Closed alecazam closed 4 years ago

alecazam commented 4 years ago

All apis seem to return a const Json& that cannot be modified. This is rather inconvenient when building a json tree to have to have all of the data up-front in a constructor, especially if conditionals are involved with what fields are saved/loaded. Am I missing an API here?

artwyman commented 4 years ago

Json objects are immutable by design. If you want to build up your data incrementally you can use a son::object (which is a type alias for a map) as a builder, then turn it into a Json object when you're done.