[Seaside] json parser patch

Lukas Renggli renggli at gmail.com
Mon Sep 12 17:07:56 UTC 2011


The problem is that what you parse is not valid JSON, check the standard on
json.org.

Lukas

On Monday, 12 September 2011, Sebastian Sastre <sebastian at flowingconcept.com>
wrote:
> Maybe this is useful to someone:
> Try this:
> JSJsonParser parseStream: '{lhs: "1 Brazil real",rhs: "0.592768 U.S.
dollars",error: "",icc: true}' readStream
> it can't parse that, so..
> ...patch it with this:
> JSJsonParser#parseProperty
> | name value |
> name := self parsePropertyName.
> value := self parseValue.
> ^ self createProperty: name with: value.
> JSJsonParser#parsePropertyName
> | result |
> result := WriteStream on: String new.
> [ stream atEnd or: [ stream peek = $: ] ]
> whileFalse: [ result nextPut: self parseCharacter ].
> ^ self expect: ':'; createString: result contents
> then you get it working like this:
>  a Dictionary('error'->'' 'icc'->true 'lhs'->'1 Brazil real'
'rhs'->'0.592768 U.S. dollars' )
> sebastian <http://about.me/sebastianconcept>
> o/
>
>
>

-- 
Lukas Renggli
www.lukas-renggli.ch
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/seaside/attachments/20110912/d8c321a4/attachment-0001.htm


More information about the seaside mailing list