Skip to content

How does from_json work? #662

@itviewer

Description

@itviewer

Sorry, I don't know if the question is right here, but I really needs help.
I need to convert json str to QString, and I defines the from_json function,

void from_json(const json& j, QString& str)
{
    str = QString::fromStdString(j.get<std::string>());
}

json object = {{"string","string"}};

then I code this ,
QString str = object["string"];
it works no problem.but when I code this,

QString str;
str = object["string"];

then the compiler do not know how to compile,error with
Error: C2593: "operator =" is not clear

Do non-built-in variables can not be pre-defined? (I tried int and double type,it can work,)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions