[Interest] QJsonValue toArray and toObject possible behavior change
Tobias Weihs
tobiasweihs at posteo.de
Wed Jun 8 12:31:07 CEST 2022
Hi,
I stumbled across what looks like a behavior change when calling
QJsonValue::toArray( defaultValue ) and QJsonValue::toObject(
defaultValue ). Example:
QJsonObject obj;
obj.insert( "object", QJsonObject() );
obj.insert( "array", QJsonArray() );
LOG_INFO( obj.value( "object" ).toObject( { { "object", 0 } } ) );
LOG_INFO( obj.value( "array" ).toArray( { "array" } ) );
In 5.8 this printed an empty object and an empty array (like I would
have expected), but in 5.15.2 this prints the default values instead.
Documentation also says if the type of the QJsonValue is not
Object/Array then the defaultValue is returned but the type is actually
correct in both versions.
Is this an intended change or am I doing something wrong? I had a quick
look into the bug tracker and couldn't find anything related. I'm also
not able to test this with any newer version.
Thanks,
Tobias
More information about the Interest
mailing list