I used this code in my controller:
result = '{ "IsLoggedIn": "%s", "resmsg": "%s"}' % (retIsLoggedIn, resmsg) 
  
response.headers['Content-Type'] = 'application/jsonp'
response.view = 'generic.jsonp' # Using python code in file 
init/views/generic.jsonp to leave data unescaped
return result

On Wednesday, October 31, 2012 7:06:06 PM UTC-5, villas wrote:
>
> I have a problem with escaping single quotes when I need a JS list in my 
> view.  I have a workaround below,  but is there a better way?  
>
> In controller:
> lst = ["Andy's Barber Shop"]
> jsonlst = json.dumps(lst)
> '["Andy\'s Barber Shop"]'
>
> In view:
> {{=XML(jsonlst)}}
> '["Andy's Barber Shop"]'   <<<<--- Broken
>
> My Workaround:
> {{=XML(jsonlst.replace("'", "\\'")}}
> '["Andy\'s Barber Shop"]'   <<<<--- Works OK
>
>
>

-- 



Reply via email to