Sunday, June 5, 2022

Re: Nested json in django rest framework

Thanks for your time I've learnt something new from your message and I solved the problem yesterday itself it was my mistake I added the wrong model to serializer

On Sunday, 5 June 2022 at 23:15:47 UTC+5:30 Kasper Laudrup wrote:
On 05/06/2022 07.06, Koushik Romel wrote:
> I want those #One and #Two to be in curly braces {} and not as square
> bracket [] , and Thanks in advance

A good start would be to understand what the difference between square
brackets and curly braces is. The JSON format is very simple:

https://en.wikipedia.org/wiki/JSON#Syntax

So you actually want to convert your array to an object with anonymous
properties/members. That doesn't really make any sense and wouldn't be
valid JSON.

Of course you could write a dirty hack and do it anyway but I seriously
doubt that's really what you want.

Hope that helps.

Kind regards,

Kasper Laudrup

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/1e14a36d-0960-4083-a208-9396340c3912n%40googlegroups.com.

No comments:

Post a Comment