QtJsonSerializer
QtJsonSerializer copied to clipboard
Sample: SerializationException (Unable to determine typeid of meta enum SampleObject::SuperFlags)
Hi,
I compiled the QtJsonSerializer, and installed.
Then try to run sample, the only change was to Sample.pro where I added CONFIG += c++1z
If I run the Sample application from the command line I get the following output:
Serializing SampleGadget:
{
"base": [
42,
13
],
"rawData": {
"someData": false
}
}
And deserializing data back:
base: QPoint(42,13)
rawData: {
"someData": false
}
Now the test object, with the previous gadget as child:
terminate called after throwing an instance of 'QtJsonSerializer::SerializationException'
what(): what: Failed to serialize with error: Unable to determine typeid of meta enum SampleObject::SuperFlags
Property Trace:
flags (Type: SuperFlags)
Annullato (core dump creato)
System is Ubuntu 16.04 with:
Qt v5.14.2
g++ v7.5.0
Register QMetaType in main.cpp
` auto obj = new SampleObject(qApp);
// Insert Next Line : Register QMetaType
qRegisterMetaType<SampleObject::SuperFlags>("SuperFlags");
obj->id = 10;
obj->title = QStringLiteral("Example");
obj->flags = (SampleObject::SuperFlag)((int)SampleObject::ValueA | (int)SampleObject::ValueB);
obj->scores = {0.0, 6.66, 47.11};
obj->secret = QStringLiteral("Very secret string, not serialized");
obj->gadget = gadget;
json = serializer.serialize(obj);
qDebug() << JSON_PRINT(json);`