[Seaside] WAJsonCanvas

Philippe Marschall philippe.marschall at gmail.com
Sat Feb 22 21:54:09 UTC 2014


On Sat, Feb 22, 2014 at 9:15 PM, Johan Brichau <johan at inceptive.be> wrote:
> Hi Esteban,
>
> I don't think you need the extra #element method.
> How about the following:
>
>         WAJsonCanvas builder render: [ :json |
>                 json array: [
>                         WADocument  allSubclasses do:[:each |
>                                 json value: [  json object: [ json key: 'name' value: each name ] ]]]
>
> this produces:
>
>         '[{"name": "WAXmlDocument"}, {"name": "WAJsonDocument"}, {"name": "WAHtmlDocument"}, {"name": "WAUnescapedDocument"}, {"name": "WAPrettyPrintedDocument"}]'
>
> But this example makes me think... I would actually want to write it as follows:
>
>         WAJsonCanvas builder render: [ :json |
>                 json array: [
>                         WADocument  allSubclasses do:[:each |
>                                 json object: [ json key: 'name' value: each name ]]]]
>
> i.e. without the #value: message. I would expect the canvas to put a comma in between different objects. An 'object' is actually a 'value' in the json syntax.
> It might make sense.

That's a pretty simple fix

WAJsonObjectBrush >> #openBrush
    canvas writeIfNotFirst: ', '.
    self document openObject

seems to do the trick. I'm a bit reluctant to commit because I'm not
sure if it will break anything. Tests are green though.

Cheers
Philippe


More information about the seaside mailing list