Replies: 1 comment 4 replies
-
If you are always going to be using it like this (note the difference between get and get_to below):
then you could just as easily skip the
|
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
First of all, the library is absolutely superb. I recently faced a situation where I wanted to write a custom
from_json
function in order to convert anlohmann::json
instance to an arbitrary type, which required additional parameters (e.g., a lookup table). Is there a way to extend theget<T>()
method with something like that? An example would look like this:And the usage of this would be something like:
Of course, it doesn't have to be the
get<T>
method, a new method like:which contains a call to the custom
from_json
function implemented by the user, just as shown in the first code snippet. And this would be useful if not everything can be initialized in the arbitrary type just from thenlohmann::json
object alone.Right now, I am unable to use the
get<T>
or anyfrom_json
functions since they do not accept additional arguments that are necessary to completely initialize the arbitrary object.I am currently not too well versed in the library, so if this request would be seen as useful, I would love one of the more proficient developers of this library to give me some pointers in how to achieve that in order to write a pull request.
Beta Was this translation helpful? Give feedback.
All reactions