Deserializing/serializing generic objects types #4773
Replies: 3 comments 6 replies
-
Example here: https://github.com/edwardcapriolo/a3a/blob/main/basic_test.cpp |
Beta Was this translation helpful? Give feedback.
-
Well I figured it out but I confess to being more confused :) The wiki I mentioned above provides this: https://www.kdab.com/jsonify-with-nlohmann-json/ NLOHMANN_JSONIFY_ALL_THINGS(request_json_params, jsonrpc, params); When I use this everything works. It would be good to include this support more native to the project. Effectively there are several old and new topics on this. If the maintainers dont want to add "variant" to the library I suggest adding the most common implementation to tests somewhere to serve as a form of contract driven development. |
Beta Was this translation helpful? Give feedback.
-
@nlohmann @gregmarr may you please critique the approach here: I borrowed the code from the all things json blog. It supports optionals, variant, and is able to support JSON inside class objects for deeply nested data.
Also the providef method/macro JSONIFY_ALL_THINGS seems to deal with polymorphism types without requiring two different methods. If you have some feedback may I can submit it as a PR. Its very powerful doing everything I need at this point. I dont see any flaws in it but my understanding is limited. Butif it makes sense I can prepare it for a contribution with unit tests etc. |
Beta Was this translation helpful? Give feedback.
-
For the JSONRPC spec a request looks like this
jsonrpc: string
id:
method:
params? object
This almost works as it can be turned from object to JSON, but not json to object
Beta Was this translation helpful? Give feedback.
All reactions