-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
basic_json templated on a "policy" class #456
Comments
You can get around the debugging issue with something like what's mentioned in this thread: namespace marton78
{
struct json : nlohmann::basic_json<>
{
using basic_json<>::basic_json;
json(basic_json<> const& j) : basic_json<>(j) {}
};
} |
I understand your points, but I currently have no capacity for such a refactoring right now. I think this would be a change in the public API, so this cannot go into a 3.x.y release. So maybe this is something for the 4.0.0. |
Do you find the approach reasonable, if it was done in a way that does not break the public API? I would be willing to try to make a patch. It's not trivial so I didn't really want to do the work unless you think it's something you would want. |
I'm not sure about this yet to be honest. |
Maybe related: #599 |
Related: nlohmann/std_json@a054558 |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
I'm enjoying the library, however I have a couple comments:
nlohmann::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long long, unsigned long long, double, std::__1::allocator, nlohmann::adl_serializer>
The mangled name is cosmetic, but it is annoying to have to try to read stackshots or prints in debuggers.
One idea I had was to refactor basic_json to be based on a policy type, aka
nlohmann::basic_json<nlohmann::default_policy>
, wheredefault_policy
would be defined something like:It would take a bit of work to get basic_json refactored in terms of the policy, and to figure out exactly what should go in each part. But I think this could make the design a bit cleaner in that it turns basic_json into the interface-glue that makes the type easy to use, and the policy object becomes the low-level details that provide a nice customization point.
The kinds of customizations that this could enable:
std::shared_ptr<json>
, orstd::unique_ptr<LazyJsonLoader>
that only deserializes a sub-object if it gets used, or to allowEmployeeRecord
to be placed directly in the union and serialized inline, but also provide conversion-operators like other types)Anyway, I just wanted to throw the idea out there to get feedback.
The text was updated successfully, but these errors were encountered: