What you get is correct. It appears that response.vars.tabs is a list
of strings and it is serialized as ["...","...",etc.]. Perhaps you
expect something different in request.vars.tabs?
You should also simplify:
def default():
f=open('/tmp/debug','w')
f.write( str( request.vars.tabs ) )
f.write( '\n' )
f.write( response.json(request.vars.tabs) )
return response.json(request.vars.tabs)
In my view :
<script>
var tabs = {{=XML(tabs)}};
</script>
On Dec 30, 12:59 pm, Chris Baron <[email protected]> wrote:
> In my controller:
>
> def default():
> f=open('/tmp/debug','w')
> f.write( str( request.vars.tabs ) ) f.write( '\n' )
> f.write( response.json(request.vars.tabs) )
> return dict( tabs = response.json(request.vars.tabs) )
>
> In /tmp/debug
>
> ["{'text': 'Tree List', 'args': {'trees': 'db.tree.id > 0'}, 'plugin':
> 'treeList'}", "{'text': 'Labels', 'args': {'eventInfo': {'labelClick':
> 'selectClade'}}, 'plugin': 'labelPanel'}", "{'text': 'Taxa', 'args':
> {'query': '( db.taxa.id > 0 ) & ( db.node.id == db.taxa.nodeId )',
> 'source': 'table'}, 'plugin': 'taxaPanel'}"]
>
> ["{'text': 'Tree List', 'args': {'trees': 'db.tree.id > 0'}, 'plugin':
> 'treeList'}", "{'text': 'Labels', 'args': {'eventInfo': {'labelClick':
> 'selectClade'}}, 'plugin': 'labelPanel'}", "{'text': 'Taxa', 'args':
> {'query': '( db.taxa.id > 0 ) & ( db.node.id == db.taxa.nodeId )',
> 'source': 'table'}, 'plugin': 'taxaPanel'}"]
>
> In my view :
>
> <script>
> ...
> var tabs = eval( "(" + {{response.write(tabs, escape=False)}} +
> ")" );
> ....
> </script>
>
> It seems that the response.json and simplejson changed with the latest
> upgrade. Also, It seems to me that the serialization should not have
> inner double quotes and only double quotes at the beginning and ending
> of the string if any at all.
>
> What is the proper way to serialize a python list into json ?