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

serialization problem, from_json need construct new object #3169

Closed
jiapengwen opened this issue Nov 30, 2021 Discussed in #3168 · 3 comments
Closed

serialization problem, from_json need construct new object #3169

jiapengwen opened this issue Nov 30, 2021 Discussed in #3168 · 3 comments
Labels
solution: duplicate the issue is a duplicate; refer to the linked issue instead

Comments

@jiapengwen
Copy link

Discussed in #3168

Originally posted by jiapengwen November 30, 2021
show you my code,:

using json = nlohmann::json;

namespace ns {
    void to_json(json& j, const person& p) {
    }
  // here will create new object, but i just want to init my object(outside create) whit json value
    void from_json(const json& j, person& p) {
    }
} // namespace ns


// in othre file
person my_person;
//here init my_person with json (j) value
from_json(j, my_person);

thank you your help

@nlohmann nlohmann added the solution: duplicate the issue is a duplicate; refer to the linked issue instead label Nov 30, 2021
@jiapengwen
Copy link
Author

I think you are misunderstood my question, i just want deserialization json to my already create object, but from_fson will create new object, this isn't my purpose

@nlohmann
Copy link
Owner

Please discuss this in #3168

@jiapengwen
Copy link
Author

ok, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
solution: duplicate the issue is a duplicate; refer to the linked issue instead
Projects
None yet
Development

No branches or pull requests

2 participants