[Interest] json file handling

Thiago Macieira thiago.macieira at intel.com
Thu Apr 16 01:21:38 CEST 2015


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()
?

(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




More information about the Interest mailing list