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

how use template <typename T> struct adl_serializer #2035

Closed
wuvalue opened this issue Apr 13, 2020 · 3 comments
Closed

how use template <typename T> struct adl_serializer #2035

wuvalue opened this issue Apr 13, 2020 · 3 comments
Labels
kind: question state: needs more info the author of the issue needs to provide more details

Comments

@wuvalue
Copy link

wuvalue commented Apr 13, 2020

template
struct adl_serializer {
static void to_json(json& j, const T& value) {
// calls the "to_json" method in T's namespace
}

static void from_json(const json& j, T& value) {
    // same thing, but with the "from_json" method
}

};

@nlohmann
Copy link
Owner

In order to asses your issue, we need the following information:

  • What is the issue you have?

  • Please describe the steps to reproduce the issue. Can you provide a small but working code example?

  • What is the expected behavior?

  • And what is the actual behavior instead?

  • Which compiler and operating system are you using? Is it a supported compiler?

  • Did you use a released version of the library or the version from the develop branch?

  • If you experience a compilation error: can you compile and run the unit tests?

@nlohmann nlohmann added the state: needs more info the author of the issue needs to provide more details label Apr 13, 2020
@ArtemSarmini
Copy link
Contributor

You specialize adl_serializer in nlohmann namespase for your types. Example is here https://github.com/nlohmann/json/blob/develop/README.md#arbitrary-types-conversions.

@nlohmann
Copy link
Owner

@wuvalue Do you need further assistance?

@nlohmann nlohmann closed this as completed May 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: question state: needs more info the author of the issue needs to provide more details
Projects
None yet
Development

No branches or pull requests

3 participants