Skip to content
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

如何序列化 QMap #11

Closed
ghost opened this issue Jul 2, 2019 · 7 comments
Closed

如何序列化 QMap #11

ghost opened this issue Jul 2, 2019 · 7 comments

Comments

@ghost
Copy link

ghost commented Jul 2, 2019

QMap <QString, QList<QString>> x;
x.insert("a", QList<QString>() << "content1" << "content2");

这个 QMap 无法转换成json

@xyz347
Copy link
Owner

xyz347 commented Jul 2, 2019

Qt没用过,所以对于Qt的各种类型不了解。
如果Qt的QMap是基于std::map那是可以用的,你的例子里面可能是由于List的原因,目前暂时还没支持List。你试一下QMap<QString, QString>的序列化,如果可以,我再支持一下std::list

@ghost
Copy link
Author

ghost commented Jul 2, 2019

    QMap <QString, QString> x;
    x.insert("a", "x");
    x.insert("bbb", "adfvdf");
    auto mm = x2struct::X::tojson(x);
    cout << mm << endl;

这段代码编译出错,x_struct_to_str 未在范围内定义


添加:把QMap 类型 改成 QMap <string, string> 并且调用 x2struct::X::tojson 时转换成 std::map 就可以运行,并且获得正确结果

@ghost
Copy link
Author

ghost commented Jul 2, 2019

建议支持 QList (或者叫 std::list )

@xyz347
Copy link
Owner

xyz347 commented Jul 2, 2019

我先支持std::list,Qt的我先了解一下。

@xyz347
Copy link
Owner

xyz347 commented Jul 3, 2019

已经支持std::list

@xyz347 xyz347 closed this as completed Jul 3, 2019
@ghost
Copy link
Author

ghost commented Jul 3, 2019

std::tuple 有没有在近期的考虑中?

@xyz347
Copy link
Owner

xyz347 commented Jul 3, 2019

std::tuple 有没有在近期的考虑中?

暂时没有考虑tuple。tuple的不定类型不好映射到json里面

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant