Im having trouble with json in mako. I do this:
${ to_json( dict( a = 1, b = 2 ) ) }
where to_json is:
<%!
import simplejson as json
def to_json( d ):
return json.dumps( d )
%>
however, instead of giving me
{"a": "1", "b": "2"}
its giving me
{"a": 1, "b": 2}
so mako changes the " to " somewhere
what should i be doing instead?
in contrast, heres a test script
import simplejson as json
print json.dumps( dict( a=1,b=2 ) )
output
{"a": 1, "b": 2}
edit
i changed my function to
<%!
import simplejson as json
def to_json( d ):
return "{\"a\": 1}"
%>
and it changes the " to "
, so its an issue with mako, it seems.