-
-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Closed
Labels
kind: questionsolution: proposed fixa fix for the issue has been proposed and waits for confirmationa fix for the issue has been proposed and waits for confirmation
Description
- Describe what you want to achieve.
- In my project with many user defined classes, JSON is used to streamlize for communication and log;
- I added only to_json() for user defined classes;
- I need to add default constructor function for all user defined classes, and it's work.
- Some user defined classes with default constructor function is meansless and useless.
My Questions is if we can ignore default constructor function when we only need to_json()?
- Describe what you tried.
- In to_json() for user defined classes, an example code for CClass is like these:
friend inline void (JSON& j, const CClass1& obj1) {
j["name1"] = obj1.strName;
j["member"] = JSON(obj1.m_obj2);
}; - In upper code, JSON is typedef nlhomann::json, obj1 is the current class object, obj2 is member class object, and maybe is STL object, i.e. vector;
- If we have all to_json() for every user defined classes, it's possiable for Arbitrary types conversions without default constructor function for those classes?
-
Describe which system (OS, compiler) you are using.
Ubuntu 18.04 LTS gcc 7.3 -
Describe which version of the library you are using (release version, develop branch).
master branch version 3.6.1
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
kind: questionsolution: proposed fixa fix for the issue has been proposed and waits for confirmationa fix for the issue has been proposed and waits for confirmation