nlohmann / std_json

A proposal for a JSON data type in the C++ standard library
54 stars 1 forks source link

Why is Json object a map and not a variant or union type. #4

Closed DhruvParanjape closed 7 years ago

DhruvParanjape commented 7 years ago

Why is it a map rather than a variant or union ? Doesn't make sense to keep it so.

DhruvParanjape commented 7 years ago

As an addendum. I am opening this issue, due to the concern of performance for when nesting takes places with object that contains objects.

Bjorn Reese's suggestion for hetrogenous containers seems like a needed requirement.

nlohmann commented 7 years ago

What is your proposal to improve performance when it comes to nesting of objects?

DhruvParanjape commented 7 years ago

sadly I have none. :( was hoping you guys might have had some thoughts for why std::map ...

mariokonrad commented 7 years ago

basic_json is a template, std::map is just the default type for the object type. The option you would have is to use a different type, like: using my_json = basic_json<..., my_fast_flat_map, ...>, as long as my_fast_flat_map meets the requirements (which are not formulated in the proposal yet).

And please note: