Skip to content

Serialize a list of class objects with json #1096

Description

@AncaMRG

Hello,
I want to serialize a list which contains a class objects. How can I do that using json. For a list of regular types I understand, but when I try to use json j_list(listName), and the listName is a list of objects I receive some errors from to_json method and 'force_msvc_stacktrace'.

This is the code.

   std::list<Student>studentList;

// populate studentList with objects of Student class

string filename = "StudentList.json";
std::ofstream output(filename, std::ofstream::out);
json js_list(studentList);
output << js_list;
output.close();

What should I do to I make this work?
Thank you! :D

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    solution: proposed fixa fix for the issue has been proposed and waits for confirmation

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions