<div dir="ltr">Hi guys, <div><br></div><div>I am trying to serialize a dictionary form Smalltalk with either NeoJSON or with Seaside&#39;s #asJson. Imagine something like this:</div><div><br></div><div><div>| infoDict stream | </div><div>stream := String new writeStream.</div><div>  infoDict := Dictionary new.</div><div><b>  infoDict at: &#39;exception&#39; put: &#39;a  &#39;&#39;escape this&#39;&#39; aa&#39;.</b></div><div><br></div><div>Note that the string of &#39;exception&#39; may contain single quotes inside. </div><div><br></div><div>Then, at some point I do:</div><div><br></div><div><b>self requestContext responseGenerator response nextPutAll: (infoDict asJson).</b></div><div><br></div><div><br></div><div>Problem is the string arrives without any escaping so....when I try to do this at client side from that string:</div><div><br></div><div>jQuery.parseJSON(variableContainingThatString);</div><div><br></div><div>I get an error as single quotes inside the double quotes do not seem allowed. </div><div>I tried a lot of combinations of <b>&quot;JSON.stringify</b>&quot; or things like:</div><div><br></div><div>variableContainingThatString<b>.replace(/[\\&quot;&#39;&#39;]/g, &#39;&#39;\\$&amp;&#39;&#39;).replace(/\u0000/g, &#39;&#39;\\0&#39;&#39;); </b></div><div><br></div><div>but none work...</div><div><br></div><div>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? </div><div><br></div><div>Thanks in advance, </div><div><br></div><div><br></div>-- <br><div class="gmail_signature">Mariano<br><a href="http://marianopeck.wordpress.com" target="_blank">http://marianopeck.wordpress.com</a><br></div>
</div></div>