-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
Help request #539
Comments
Can you provide the code you try to compile? |
Ok, but the problem that I work on specifec private project.
|
In line You need to define a method |
We could add support for enum classes too, this is quite trivial, and won't conflict with existing |
That would be great. Is this related to #513? |
Yes it is! |
Is it necessary that the method have two arguments, we cannot define it only with first argument (json)? |
No, it has to have two arguments. |
Because I get the same error, despite I define it with two arguments. |
Did you try what I proposed in #539 (comment)? |
yes I tried, you will find my test in this code. #include "StdAfx.h"
#include <iostream>
#include <stdio.h>
#include "GUI_DescrLib.h"
#include "BaseDir.h"
#include "D:\Sources\serialization_avec_json&GUIdescr2015\json-develop\json-develop\src\json.hpp"
using nlohmann::json;
using namespace LtXmlLib5;
using namespace std;
using namespace GUI_DescrLib;
// forward declarations
void to_json(json& j, const CClassFactory & p, GUI_DescrLib_Classes eCls, LPCTSTR strElementName);
/// <summary>
/// The main entry point for the application.
/// </summary>
int main(int argc, char* argv[])
{
system("pause");
return 0;
}
void to_json(json& j) {
GUI_DescrLib_Classes eCls = ClsName_CBaseDir;
CBaseDirPtr elm = CBaseDir::CreateInstance();
j = json{ { "name", CBaseDir::GetparentElement() },{ "address", CBaseDir::Getelementinfo() },{ "age", CBaseDir:: Getattributrinfo() } };
} |
You need to define the |
The problem that the class type is a singleton, so Ihave to create one and only one instance of this class. |
I don't understand. The |
As I said in the previous comment, the classes in my project are singletons and their attributes are static. So can I define thes method in the classes as a static method? |
I see. Then you cannot use this mechanism. You can define any function that returns a json. |
btw: this is a strange implementation of a singleton as you have no instance at all. If you follow approaches like http://stackoverflow.com/questions/1008019/c-singleton-design-pattern you would have exactly one instance and could the approach described in the README. |
Good morning, |
See #539 (comment) |
To my mind, Ihave to add my one "adl_serializer", would do you please show an example of it.
But I get this error "syntax error;identifier'json'". |
Did you add |
There is an example with |
Hello,
I want to thank you for the important advice. I get what I want but with simple class.
When I tried your solution with singleton and other specific classes. I got this error "C2338 could not find to _json() method in T's namespace ".
Really, I need your help for advancing as soon as possible.
thank you in advance,
Best regards,
The text was updated successfully, but these errors were encountered: