[Development] [RFO QTBUG-84739] QJsonValue::fromVariant containing QByteArray

Thiago Macieira thiago.macieira at intel.com
Fri Jul 3 02:49:09 CEST 2020


On Thursday, 2 July 2020 15:46:24 PDT Tor Arne Vestbø wrote:
> I think I prefer permanently, and then clearly documenting that the fallback
> conversion to a string for non-listed types may be lossy, teaching the user
> to either encode the data into one of the well defined and non-lossy types
> (e.g. use a QString if what you're representing is a string, or
> base64-encode raw binary data), or use CBOR instead.
 
> That leaves less amount of surprises when upgrading to Qt 6 while being
> clear about the possible downsides.

Thank you.

For Qt 6, I think we should look at the list of meta types and explicitly list 
how they are converted to CBOR and JSON, so for QByteArray it would be clear 
that it's a lossy conversion using fromUtf8. Any type not in the white list 
gets converted to JSON null or CBOR undefined but subject to change.

And unit-test them.
-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel System Software Products





More information about the Development mailing list