On Wednesday 15 April 2015 19:28:49 Andre Somers wrote: > On 15-4-2015 17:25, Thiago Macieira wrote: > > On Wednesday 15 April 2015 16:36:15 André Somers wrote: > >>> The dilemma I'm in is, how can I tell the json writer to "append" to a > >>> current json file without loading the whole file back in memory (eg > >>> read json from file->edit in Qt->write back to file). Because, after a > >>> while, I suppose the file will get quite large. > >> > >> I don't think JSON is particulary suitable for this kind of application > >> (and neither is XML). > > > > CBOR might be, since it does support "undefined length" maps and arrays. > > I'm not familiar with that format, but I'll look it up. I guess the > choice for JSON or XML is made due to convenience though, as classes to > read and write these are readily available. I doubt the same can be said > of CBOR.
RFC 7049. > > As for XML, the format may not be suitable but QXmlStreamWriter is since > > it > > keeps the state of which tags it needs to close and allows you to simply > > stream data into it. On the receiver side, QXmlStreamReader is capable of > > receiving incomplete data and making the best it can with what has been > > completed. > > I'd expect a log-file like output to be well defined at any moment in > time, or as close as possible to that. So, while QXmlStreamWriter is > suitable, it does not produce a valid XML file until you finalize the > write. That may not be what you want (even though QXmlStreamReader could > be used to parse the incomplete file*). Yeah, that makes sense. Then for CBOR you wouldn't have the array header (byte 0x9f), but simply have a sequence of items. Or your parser should recover from having an unterminated array. -- Thiago Macieira - thiago.macieira (AT) intel.com Software Architect - Intel Open Source Technology Center _______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest