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 not work.

Any idea?




On 23 Nov., 15:05, Li You <vbs0...@gmail.com> wrote:
> sorry but a mistake.
>
>
>
> On Tue, Nov 23, 2010 at 10:01 PM, Li You <vbs0...@gmail.com> wrote:
> > 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']
>
> ~~~ should be
> print d['fields']['author']
>
>
>
>
>
> > On Tue, Nov 23, 2010 at 9:45 PM, alecx
> > <alexander.robert.h...@googlemail.com> wrote:
> >> 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/#deserializ...
>
> >> In javascript i can get e. g. the "name": "Mostly Harmless" with:
> >> this.fields.name.
> >> But how do i get the "author": ["Douglas", "Adams"]?
> >> I tried serveral options, but had no luck.
>
> >> --
> >> You received this message because you are subscribed to the Google Groups 
> >> "Django users" group.
> >> To post to this group, send email to django-us...@googlegroups.com.
> >> To unsubscribe from this group, send email to 
> >> django-users+unsubscr...@googlegroups.com.
> >> For more options, visit this group 
> >> athttp://groups.google.com/group/django-users?hl=en.
>
> > --
> > Best Regards!
>
> > Li You
> > University of Science and Technology of China
>
> --
> Best Regards!
>
> Li You
> University of Science and Technology of China

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to