The documentation for jsexpr? states that JS-expressions use symbols as keys for hash tables, and strings for all other JSON-strings. Presumably this is to improve the efficiency of hash table lookup.<br><br><a href="http://docs.racket-lang.org/json/index.html">http://docs.racket-lang.org/json/index.html</a><br>
<div class="gmail_extra"><br clear="all">Carl Eastlund<br>
<br><br><div class="gmail_quote">On Tue, Dec 4, 2012 at 2:21 PM, Scott Klarenbach <span dir="ltr"><<a href="mailto:scott@pointyhat.ca" target="_blank">scott@pointyhat.ca</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Is this a bug with the json module, or am I missing something about the implementation?<div><br></div><div>It seems it crashes when serializing a hashtable that has strings for keys. Symbols work fine.</div><div><br></div>
<div>ie,</div><div><br></div><div>>> (jsexpr->string (hash "id" 1 "title" "core"))</div><div>write-json: expected argument of type <bad JSON key value></div><div><br></div><div>
BUT this works:</div><div><br></div><div>>> (jsexpr->string (hash 'id 1 'title "core"))</div><div>"{\"id\":1,\"title\":\"core\"}"<br clear="all"><div><br>
</div>-- <br>Talk to you soon,<br><br>Scott Klarenbach<br><br>PointyHat Software Corp.<br><a href="http://www.pointyhat.ca" target="_blank">www.pointyhat.ca</a><br>p <a href="tel:604-568-4280" value="+16045684280" target="_blank">604-568-4280</a><br>
e <a href="mailto:scott@pointyhat.ca" target="_blank">scott@pointyhat.ca</a><br>
#308 - 55 Water St.<br>Vancouver, BC V6B1A1<br><br>_______________________________________<br>To iterate is human; to recur, divine<br>
</div>
<br>____________________<br>
Racket Users list:<br>
<a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
<br></blockquote></div><br></div>