> Sent: Wednesday, April 15, 2015 at 7:21 PM
> From: "Thiago Macieira" <thiago.macie...@intel.com>
> To: interest@qt-project.org
> Subject: Re: [Interest] json file handling
>
> On Wednesday 15 April 2015 20:27:00 Jason H wrote:
> > Anyway, when converting structured data, you can imagine everything as those
> > four functions. push():  add an item (or key) to a list
> > pop(): end the list
> > item(key): create an item with key
> > value(value): set the value of the last item.
> > 
> > {"this": "is", "some": {"1": "JSON"} } =
> > push().item('this').value('is').item('some').push().item('1').value('JSON').
> > pop().pop()
> 
> What happens if you do
> 
>       push().item('this').item('some').value('is').value(1).pop().pop().push()
> ?
It depends on your serialization rules, you could get the equivalent of "{this: 
null, some:1}," as the first object and "{" textually or {null: null} as a 
second object, if the serializer allows multiple root elements, otherwise only 
the second object. The serializer should examine the stack, and add implicit 
pops as needed, so that your example would imply a .pop(), which would then 
give you "{}" textually or {} objectively.

Not all possible sequences need to be valid. Also, you could provide a push() 
that takes a key, which expands to lizatoion rulespush().item(key)


I've used this for processing TONS of various data and trivially mapping across 
DICOM, XML, JSON, SQL (not as trivial, but still easy with a static schema).

> (I think I inserted 4 errors there)
> 
> > Don't forget though with JSON, there is only ever one root element, which is
> > a dictionary. You can't have your root JSON be and array [], or a bunch of
> > items "1,2,3" or {},{},{}, they all must be in a {"root: _items_{}_or_[]__
> > } Which means you will always need a closing '}'
> 
> You definitely can an array.
> 
> And apparently there's a new standard saying that the root element could also 
> be a string, number, boolean or null. Not very useful, though.
> 
> -- 
> 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
> 
_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to