Commit 02645b25 authored by EXT Arnaud Clère's avatar EXT Arnaud Clère

Fixed QJsonReader when !_item()

parent 205594e6
......@@ -859,7 +859,7 @@ TResult qbind(Val<TResult>&& v, T* t) {
auto rw = v->mode();
auto mo = T::staticMetaObject;
auto r = v.meta(qmName,QAsciiData(mo.className())).record();
for (int i = 0; i<mo.propertyCount(); i++) {
for (int i = 0; r && i<mo.propertyCount(); i++) {
auto p = mo.property(i);
if (p.isStored()) {
if (rw==Read) {
......
......@@ -345,7 +345,7 @@ protected:
}}
bool _item(QIdentifier& k) { if (caching) { return caching->_item(k); }
Step& level = levels.last();
if (-1 < level.index && !get(',',level.end)) {
if ((-1 < level.index && !get(',',level.end)) || next("[{\"ntf-0123456789.",'}')=='}') {
return false;
}
level.index++;
......@@ -357,7 +357,7 @@ protected:
return get(':',level.end); }
bool _item( ) { if (caching) { return caching->_item(); }
Step& level = levels.last();
if (-1 < level.index && !get(',',level.end)) {
if ((-1 < level.index && !get(',',level.end)) || next("[{\"ntf-0123456789.",']')==']') {
return false;
}
level.index++;
......
......@@ -733,8 +733,8 @@ int main(int argc, char *argv[])
GROUP("Person<>Json")//====================================================
{
QBuffer json; json.open(QIODevice::ReadOnly);
json.buffer() = "_{ \"names\": [ _\"John\" _, \"Doe\"] , \"age\"_:_null, \"height\":_1.75, \"phones\": [], \"\":\"superfluous item\" _} ";
// 1 15 23 4042 58 101
json.buffer() = "_{ \"names\": [ _\"John\" _, \"Doe\"] , \"age\"_:_null, \"height\":_1.75, \"phones\": [], \"_\":\"superfluous item\" _} ";
// 1 15 23 4042 58 102
Person p;
QBuffer roundtrip; roundtrip.open(QIODevice::ReadWrite);
QJsonValue jv;
......@@ -776,15 +776,20 @@ int main(int argc, char *argv[])
//---------------------------------------------------------------------
START {
roundtrip.seek(0); jv = QJsonValue();
QJsonReader r(&roundtrip); // FIXME
QJsonReader r(&roundtrip);
r.bind(jv);
readerErrors = r.errors;
}
STOP("Json>JsonValue",QJsonDocument(jv.toObject()).toJson(QJsonDocument::Compact)+" | "+Text(readerErrors));
// TODO JsonValue>Json
// TODO
// START {
// ba.resize(0);
// QJsonWriter(&ba).bind(jv);
// }
// STOP("JsonValue>Json",ba);
START {
roundtrip.seek(0); ba.resize(0);
QJsonReader r(&roundtrip); // FIXME
QJsonReader r(&roundtrip);
r.bind(QCborWriter(&ba).value());
readerErrors = r.errors;
}
......
......@@ -56,13 +56,13 @@ Bindable |
Bindable>Cbor |bf647479706502666e756d6265726b2b34342031323334353637ff
Bindable>Json |{"type":2,"number":"+44 1234567"}
Person<>Json |================================================================================
Json>P |(Person)[ names:[ John Doe] height:1.75 age:-1 phones:[] comments: children:[]] | [ IgnoredCharacter 0:1 IgnoredCharacter 0:15 IgnoredCharacter 0:23 IgnoredCharacter 0:40 IgnoredCharacter 0:42 IgnoredCharacter 0:58 IgnoredCharacter 0:76 IgnoredCharacter 0:77]
Json>P |(Person)[ names:[ John Doe] height:1.75 age:-1 phones:[] comments: children:[]] | [ IgnoredCharacter 0:1 IgnoredCharacter 0:15 IgnoredCharacter 0:23 IgnoredCharacter 0:40 IgnoredCharacter 0:42 IgnoredCharacter 0:58 IgnoredCharacter 0:102]
P>Json |{"names":["John","Doe"],"height":1.7500000000000002,"age":-1,"phones":[],"comments":"","children":[]}
Json>P |(Person)[ names:[ John Doe] height:1.75 age:-1 phones:[] comments: children:[]] | [ IgnoredCharacter 0:72 IgnoredCharacter 0:73 ExpectedRecord 0:73]
Json>P |(Person)[ names:[ John Doe] height:1.75 age:-1 phones:[] comments: children:[]] | []
P>JsonValue |{"age":-1,"children":[],"comments":"","height":1.7500000000000004,"names":["John","Doe"],"phones":[]}
JsonValue>P |(Person)[ names:[ John Doe] height:1.75 age:-1 phones:[] comments: children:[]] | []
Json>JsonValue|{"age":-1,"height":1.7500000000000004,"names":["John","Doe"],"phones":["comments","children"]} | [ IgnoredCharacter 0:72 IgnoredCharacter 0:73 IgnoredCharacter 0:84 IgnoredCharacter 0:85 IgnoredCharacter 0:86 IgnoredCharacter 0:98 IgnoredCharacter 0:99]
Json>Cbor |bf656e616d65739f644a6f686e63446f65ff66686569676874fa3fe0000063616765206670686f6e65739f68636f6d6d656e7473686368696c6472656effff
Json>JsonValue|{"age":-1,"children":[],"comments":"","height":1.7500000000000004,"names":["John","Doe"],"phones":[]} | []
Json>Cbor |bf656e616d65739f644a6f686e63446f65ff66686569676874fa3fe0000063616765206670686f6e65739fff68636f6d6d656e747360686368696c6472656e9fffff
Person<>Cbor |================================================================================
Cbor>P |(Person)[ names:[ John Doe] height:1.75 age:-1 phones:[] comments: children:[]] | []
P>Cbor |bf656e616d65739f644a6f686e63446f65ff66686569676874fb3ffc00000000000063616765206670686f6e65738068636f6d6d656e747360686368696c6472656e80ff
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment