[PD] Announcing CouchPdb development
Thomas Mayer
thomas at residuum.org
Thu Sep 8 22:49:06 CEST 2011
Hello all,
On 03.09.2011 18:36, Mathieu Bouchard wrote:
> On Wed, 31 Aug 2011, Thomas Mayer wrote:
>
>> I came up with lists: The example above outputs now on the left outlet
>> list id 1
>> list name my\ name
>> list year 2011
>
> Yes, that sounds like the appropriate thing to do with Pd.
>
>> After a JSON object is decoded, I output a bang on a second outlet, and
>> therefore can distinguish between two objects in short succession.
>
> Yes, either that or an 'end' message on the first inlet, but what you
> did is more usual.
Here is what I came up for arrays and nested objects:
If they come up inside an object, they are output as the symbol that
they are. The JSON string can then be parsed by another instance of
[json-decode] (or send it recursively to the same object).
Arrays as symbols themselves are parsed like several seperate objects.
Here is an example:
Consider the JSON string
{"id": 1, "name": "Residuum","member": {"first-name": "Thomas",
"last-name": "Mayer"}, "albums": [{"year": 2011, "name": "Der
Diskokeller des Grauens"}, {"year": 2009, "name": "Schrei-Funk-Flaeche"}]}
When parsed with an instance of [json-decode] this will output
list id 1
list name Residuum
list member {"first-name": "Thomas", "last-name": "Mayer"}
list albums [{"year": 2011, "name": "Der Diskokeller des Grauens"},
{"year": 2009, "name": "Schrei-Funk-Flaeche"}]
followed by a bang on the second outlet.
When parsing the array for "albums", i.e.
[{"year": 2011, "name": "Der Diskokeller des Grauens"}, {"year": 2009,
"name": "Schrei-Funk-Flaeche"}]
This will output:
list year 2011
list name Der\ Diskokeller\ des\ Grauens
bang on second outlet
list year 2009
list name Schrei-Funk-Flaeche
bang on second outlet
The current version is available at https://github.com/residuum/CouchPdb
Thanks for reading,
Thomas
--
"[D]ie Kunst flieht, wenn ihr eure Thaten sofort mit dem historischen
Zeltdach überspannt." (Friedrich Nietzsche - Vom Nutzen und Nachtheil
der Historie für das Leben)
http://www.residuum.org/
More information about the Pd-list
mailing list