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

WIP: QT (cute) type supports #1869

Closed
42sol-eu opened this issue Dec 13, 2019 · 4 comments
Closed

WIP: QT (cute) type supports #1869

42sol-eu opened this issue Dec 13, 2019 · 4 comments
Labels
kind: enhancement/improvement state: stale the issue has not been updated in a while and will be closed automatically soon unless it is updated

Comments

@42sol-eu
Copy link

  • Describe the feature in as much detail as possible.

add a feature_flagged function the nlohmann::json(::magic) to support Qt-Datatypes
I would at least start implementing that if someone would coach me through!

good examples: easylogging++

  • Include sample usage where appropriate.
QMap<QString, MyData> data = json_data; // converted with nlohmann::json::magic ;-)

QMap<std::string, MyData> data = json_data; 

QVector<QVariant> string_list = json_data;
@nlohmann
Copy link
Owner

This should be all possible via the to_json/from_json functions, described in https://github.com/nlohmann/json#arbitrary-types-conversions.

@42sol-eu
Copy link
Author

so i I would implement a json_qt.hpp with the to_json(... QMap<> ...) and from_json( ... QMap<>) the QT type system could be included?

often it is only like a std-library type e.g.

void to_json(json j, QString d )
{
    j =  d.toStdString()
}

void from_json(json j, QString d )
{
    d = QString::fromStdString( j.get_as<std::string>)
}

I was wondering where you implemented it for std:vector and std::list - maybe this would be a great template for the QT containers (by the way I hate them and would replace them with std-library containers as soon as possible, but ...)

@nlohmann
Copy link
Owner

I would not like to add the conversions from/to Qt to the library as it would then depend on the Qt headers. But all conversions are possible via to_json/from_json functions, so you could create your own json_qt.hpp header.

@stale
Copy link

stale bot commented Jan 15, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the state: stale the issue has not been updated in a while and will be closed automatically soon unless it is updated label Jan 15, 2020
@stale stale bot closed this as completed Jan 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: enhancement/improvement state: stale the issue has not been updated in a while and will be closed automatically soon unless it is updated
Projects
None yet
Development

No branches or pull requests

2 participants