Leveraging the to_json from_json() with nlohmann::json* #2611
Unanswered
mynameismichael
asked this question in
Q&A
Replies: 1 comment 3 replies
-
If you want to store a pointer to a JSON value built out of a |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
I am using this json library and I have a specific use case. I am parsing URI's for a REST API to modify parameters on the fly (to an embedded device) via a web interface.
So far, I have added the macros for serialisation and they are a dream. They work great, but the real issue is now I need to create a hash table for efficiency to map URI’s to types that can be serialised/deserialised.
The issue I am encountering is that I would like to do something as follows:
I am able to benefit from the =operator auto serialisation of my data structures with the macro, but also I need the nlohmann::json object to be a pointer, because in operation, the data will be changing and I cannot have my hash-table storing old data. Also, to regularly refresh the hash table would be expensive, as there would be many items.
So whilst my data structures all vary in types (many custom data structures), they have benefitted from the macros. But now I need some kind of reference or pointer to them all with the same type, rather than lots of functions, I was hoping this could be achieved with nlohmann::json* but it doesn’t appear to be the case.
I am wondering if anybody has ever tried such a thing, or an area of the documentation you may point me to. I feel what I would like to achieve shouldn’t be so difficult.
Am I missing something?
Beta Was this translation helpful? Give feedback.
All reactions