Skip to content
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

nlohmann::adl_serializer<T,void>::to_json no matching overloaded function found #1641

Closed
yoro3000 opened this issue Jun 16, 2019 · 2 comments

Comments

@yoro3000
Copy link

yoro3000 commented Jun 16, 2019

I want to serialize a vector of a type I created. (ex: std::vector< RoomData >)

So I used the to_json function on the class RoomData:
Screenshot_61

And serialize it like that: (res.rooms is std::vector< RoomData >)
Screenshot_62

*Both are found on the same file (the to_json file at the top)

but I'm getting those errors:

  1. nlohmann::adl_serializer<T,void>::to_json no matching overloaded function found (File: json.hpp, line 1256)
  2. Failed to specialize function template 'unknown-type nlohmann::adl_serializer<T,void>::to_json(BasicJsonType &, ValueType &&) noexept()' (File: json.hpp, line 1256)

I'm using the latest version.

Any idea where is this coming from?

@nickaein
Copy link
Contributor

Section Arbitrary types conversions might be helpful. Have you tried marking RoomData& parameter of to_json as a const reference?

As a sidenote, thanks for posting the code as clean and readable. You can also use builtin Markdown support for posting styled code in Github as described here (Examples section under the Codes tab). The plus would be that the code will be copy-able and searchable.

@yoro3000
Copy link
Author

Section Arbitrary types conversions might be helpful. Have you tried marking RoomData& parameter of to_json as a const reference?

As a sidenote, thanks for posting the code as clean and readable. You can also use builtin Markdown support for posting styled code in Github as described here (Examples section under the Codes tab). The plus would be that the code will be copy-able and searchable.

Thank you very much, that was my problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants