diff --git a/tests/QBind/QBind_impl.h b/tests/QBind/QBind_impl.h index 994f6e15a44e02e480193c3125f1f52ad45991c8..046765a79a51eb38cc5e43f4467364b11d6b92fa 100644 --- a/tests/QBind/QBind_impl.h +++ b/tests/QBind/QBind_impl.h @@ -859,7 +859,7 @@ TResult qbind(Val&& 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_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++; diff --git a/tests/QBind/main.cpp b/tests/QBind/main.cpp index 7d41b799c49638dbacd40a1927561f491035e12f..0dbf5bb29c2d23cc2d018663aedcda8ee1f5dbff 100644 --- a/tests/QBind/main.cpp +++ b/tests/QBind/main.cpp @@ -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; } diff --git a/tests/QBind/samples.txt b/tests/QBind/samples.txt index 8b70bb98b3dff37efa1a6ca4243975b1af5d667b..b25e102da210a7243257ceb639a774b09fb12b87 100644 --- a/tests/QBind/samples.txt +++ b/tests/QBind/samples.txt @@ -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