Hi guys,
I am trying to serialize a dictionary form Smalltalk with either NeoJSON or with Seaside's #asJson. Imagine something like this: | infoDict stream | stream := String new writeStream. infoDict := Dictionary new. infoDict at: 'exception' put: 'a ''escape this'' aa'. Note that the string of 'exception' may contain single quotes inside. Then, at some point I do: self requestContext responseGenerator response nextPutAll: (infoDict asJson). Problem is the string arrives without any escaping so....when I try to do this at client side from that string: jQuery.parseJSON(variableContainingThatString); I get an error as single quotes inside the double quotes do not seem allowed. I tried a lot of combinations of "JSON.stringify" or things like: variableContainingThatString.replace(/[\\"'']/g, ''\\$&'').replace(/\u0000/g, ''\\0''); but none work... So..I wonder...can I simply escape this from server side at the time I serialize to JSON? Any special way of doing this or I hack on the resulting string? Thanks in advance, _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
Hi Mariano,
I am not sure what your specific problem is, but strings in JSON are delimited with double quotes and only double quotes should be escaped, not single quotes. https://tools.ietf.org/html/rfc7158#page-8 NeoJSONWriter toString: { 'exception' -> 'a ''escape this'' aa' } asDictionary. "'{""exception"":""a ''escape this'' aa""}'" STON uses single quoted strings (like Smalltalk), hence escapes them. STON toString: { 'exception' -> 'a ''escape this'' aa' } asDictionary. "'{''exception'':''a \''escape this\'' aa''}'" Note the confusing escaping done by Smalltalk, better inspect the results !! This won't solve your problem though, I know. Sven > On 23 Feb 2016, at 17:37, Mariano Martinez Peck <[hidden email]> wrote: > > Hi guys, > > I am trying to serialize a dictionary form Smalltalk with either NeoJSON or with Seaside's #asJson. Imagine something like this: > > | infoDict stream | > stream := String new writeStream. > infoDict := Dictionary new. > infoDict at: 'exception' put: 'a ''escape this'' aa'. > > Note that the string of 'exception' may contain single quotes inside. > > Then, at some point I do: > > self requestContext responseGenerator response nextPutAll: (infoDict asJson). > > > Problem is the string arrives without any escaping so....when I try to do this at client side from that string: > > jQuery.parseJSON(variableContainingThatString); > > I get an error as single quotes inside the double quotes do not seem allowed. > I tried a lot of combinations of "JSON.stringify" or things like: > > variableContainingThatString.replace(/[\\"'']/g, ''\\$&'').replace(/\u0000/g, ''\\0''); > > but none work... > > So..I wonder...can I simply escape this from server side at the time I serialize to JSON? Any special way of doing this or I hack on the resulting string? > > Thanks in advance, > > > -- > Mariano > http://marianopeck.wordpress.com > _______________________________________________ > seaside mailing list > [hidden email] > http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
f := html form. f with:[ And when looking at generated page source: <form accept-charset="utf-8" method="post" action="/uploader?_s=jdXt_Vzp8dKoK3M9&_k=C197PyH7ka66mXVd"> So, how to hack my own action into the form? thanks Robert _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
Hi!
The WABrush>>with: call must be the last call to a brush. So instead of: html form with: [ stuff… ]; Try: I have tried and it works :) Cheers! Alejandro
_______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
Thanks! I'll go like this.Alejandro Infante <[hidden email]> ezt írta (időpont: 2016. márc. 1., K, 17:22):
_______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
Free forum by Nabble | Edit this page |