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

Easy serialization of classes #280

Closed
jonasseglare opened this issue Jul 12, 2016 · 2 comments
Closed

Easy serialization of classes #280

jonasseglare opened this issue Jul 12, 2016 · 2 comments

Comments

@jonasseglare
Copy link

I am currently using msgpack to serialize my objects in C++, but the msgpack is not human readable, so I am looking at using JSON. The msgpack-c++ library has a very neat macro called MSGPACK_DEFINE which, in one line, adds msgpack serialization to a class, so that it can be serialized/deserialized to the msgpack format. See example here: https://github.com/msgpack/msgpack-c/wiki/v1_1_cpp_adaptor#intrusive-approach

#include <msgpack.hpp>

struct your_class {
    int a;
    std::string b;
    MSGPACK_DEFINE(a, b);
};

Does this JSON library feature a similar functionality? It would be very useful.

@nlohmann
Copy link
Owner

I have not thought about going into the serialization business - I think it is a lot of work to do right, and that with cereal there is already a great library for this.

@nlohmann
Copy link
Owner

FYI: A nice serialization/deserialization for arbitrary types is now implemented: see #328.

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