Hello django users,
after several try outs, i am not able to figure out how to access data
in a serialized object.
E. g. how do I get the name "Douglas", "Adams" in the example:
http://docs.djangoproject.com/en/dev/topics/serialization/#deserialization-of-natural-keys
In javascript i can get e. g
Maybe this is what you want:
from json import JSONDecoder
s = '''{
"pk": 1,
"model": "store.book",
"fields": {
"name": "Mostly Harmless",
"author": ["Douglas", "Adams"]
}
}
'''
d = JSONDecoder().decode(s)
print a['fields']['author']
On Tue, Nov 23, 2010 at 9:45 PM
sorry but a mistake.
On Tue, Nov 23, 2010 at 10:01 PM, Li You wrote:
> Maybe this is what you want:
>
> from json import JSONDecoder
> s = '''{
> "pk": 1,
> "model": "store.book",
> "fields": {
> "name": "Mostly Harmless",
> "author": ["Douglas", "Adams"]
> }
> }
> '''
>
Thanks for your answer Li.
This solution works for python, I figured this out too.
But how does this work inside a template with javascript?
I use $.getJSON() inside the template to get the data.
Inside the javascript I can access the data with:
this.fields.name
but
this.fields.author
does n
4 matches
Mail list logo