On Wednesday, June 8, 2016 at 4:00:48 AM UTC-4, Alex Glaros wrote:
>
> I cannot make JSON data correctly. (The result of below has duplicate data 
> with the word <Row: 
>
> result = dict()
> for r in new_roots:
>    result[r] = '{"title": '  +  '"' + r.taxonomy_column_name +  '"' +   ', 
> "key":' +   str(r.id) +  ', "parentId":' + '2' + ', "folder": false, 
> "lazy": true},'
>

It appears that r is a Row object, and yet you are using it as a key in the 
result dictionary -- so you are getting exactly that, a dictionary whose 
keys are Row objects. Perhaps you instead want to use the row id as a key: 
result[r.id] = ...

Anyway, this is not the way to construct JSON. Instead, just construct a 
Python data structure of dictionaries and lists and use json.dumps() to 
convert it to JSON.

Anthony

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to