On Wednesday, 9 June 2021 07:15:37 PDT Jérôme Godbout wrote: > I understand the homogenous part when you do decoding, but encoding to json > should support the homogenous, isn’t? why not? I understand that the decode > of that json would alter the type. > > QList<QVariantMap> • encode json • [{‘a’: ‘b’}, {‘c’:’d’}] • decode json • > QList<QVariant>
I don't understand the question. Please rephrase without saying "encode json". There's no encoding to JSON format here. There's only a translation between two different types of data structures: a QVariant-based collection and the QJsonDocument's internal representation. > Should be possible as long as QList<T> where T can be convert to QVariant. > Maybe an external converter function should be used. If this is not > supported, is there a way where we could trap this at compile time warning? > > Maybe there is a limitation I do not see here. That would require us to add a new function to the meta type of all registered types that convert them to QVariant and possibly also from it. There's no such thing in QMetaType right now. Moreover, it would require us to know that QList<T> is a list of T. There may be hope for that in QSequentialIterable, but that's black magic in Qt I *refuse* to touch. I'll pretend it doesn't exist and will not add support for it in the QJsonValue/QCborValue to/from QVariant conversion code. I may even reject submissions adding them because they would increase my maintenance burden. -- Thiago Macieira - thiago.macieira (AT) intel.com Software Architect - Intel DPG Cloud Engineering _______________________________________________ Interest mailing list Interest@qt-project.org https://lists.qt-project.org/listinfo/interest