[Seaside] WAJsonCanvas
Esteban A. Maringolo
emaringolo at gmail.com
Fri Feb 21 15:23:35 UTC 2014
I migrated to Seaside 3.1, and I had a mix of NeoJSON and old style
#jsonOn: implementations.
By fixing the old style #jsonOn: to work with a WAJsonCanvas, I found
I don't have a way to create an array definition specifying each
element.
It is, the implementation delegates the rendering to the Collection
class, but I can't control it to do it manually:
However, I implemented an #element: selector in WAJsonCanvas as follows:
WAJsonCanvas>>#element: aValueObject
^ (self brush: (WAJsonElementBrush new)) with: aValueObject
And then I could do:
WAJsonCanvas builder render: [ :json |
json array: [
WADocument allSubclasses do:[:each |
json element: [
json object: [ json key: 'name' value: each name ]
]
]
]
]
which generates the following output:
[{"name": "WAXmlDocument"}, {"name": "WAJsonDocument"}, {"name":
"WAHtmlDocument"}, {"name": "WAUnescapedDocument"}, {"name":
"WAPrettyPrintedDocument"}]
Without using the #element: brush all the elements aren't comma
separated. Maybe there is another way of doing it, delegating it to
the array brush.
Is this okay? Can this be added to Seaside-JSON-Core?
Regards,
Esteban A. Maringolo
More information about the seaside
mailing list