-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
Is there a nice way to associate external values with json elements? #1256
Comments
Well, no response, so I would like to modify my question to be: What is the best way to modify your library to allow for custom values bound to elements. using caching_json = ...::basic_json<caching_class>; I think I would also need to change swap, to call a base class swap if there is one, I guess. Would this be the best way to go about it? Can you think of a better way? |
I am currently not aware of a nice means to extend the class. Any help appreciated. |
Maybe related: #1201. |
We can't extend it via deriving from basic_json and then declaring the manipulating the template parameter of the allocator, because the object_t map is a map of basic_json and not a map of basic_json*. I think the above statement is true. I could be wrong. This means that in order to associate external values we must either 1. have another template parameter, "customization field", 2. or change basic_json's derivation. I think the above statement is true. I could be wrong. There are other options of using the deserialization listener of the json to create a parallel structure, but I am trying to avoid that, at least in theory.
On the copy, swap methods of the json, you would need to copy and swap the external values as well. This would be trivial, and incorporating different structures, one would merely need to specialize whatever template method is used to do this copy/move/etc. For an empty structure external value, I would assume the compiler would optimize these extra instructions out, and indeed, I would guess that the memory size of the json class would not change. I'm guessing it would be maybe 10-20 extra lines of code.
Those are my thoughts at the moment. |
So idea 1 would just mean that you add an arbitrarily-typed (public?) member variable to the |
Yep. Seems dirty. Lol. But if it were an empty struct by default... I would guess it would be optimized out. |
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 am contemplating caching deserializations of json subtrees within the json tree.
Is there a clean way of doing this without modifying your code?
The text was updated successfully, but these errors were encountered: