Closed
Description
Hi,
I have a 3rd party SDK included in my project that has class declarations like below -
Let's assume the class name as Person (simplified the code for reporting purposes) -
class _declspec(dllimport) Person
{
public std::string name;
}
I am trying to serialize the class using the below to_json
function as mentioned in the documentation -
#include <Person.h>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
void to_json(json& j, Person & o)
{
j = json{ { "value", o.name } };
}
Person p = new Person();
p.name = "Test";
json j = p;
However even though everything is syntactically correct, I am getting the below errors on building my project -
could not find to_json() method in T's namespace
'force_msvc_stacktrace': is not a member of 'Person'
'force_msvc_stacktrace': undeclared identifier
forcing MSVC stacktrace to show which T we're talking about.
I have also tried creating a simple class without the _declspec(dllimport)
and that works like a charm.
Can someone please help in this regard?
Details:
- Compiler: Visual Studio 2017
- Operating System: Windows