Hi, I am trying to create an API that will provide JSON data that is based on Roku JSON specification (https://developer.roku.com/en-ca/docs/specs/direct-publisher-feed-specs/json-dp-spec.md). The specification requires that the JSON data is a single object { }, not a list array [ ]. So far I am not able to setup the APIView to render JSON data as an object { }.
The ListAPIView always serializes the JSON to an array and not a single object. However, RetrieveAPIView serializes the JSON as a single object. A sample of the Roku JSON feed: https://devtools.web.roku.com/samples/roku-developers-feed-v1-rdp.json I am fairly new to this, and learning as I go. code: ``` class RokuContentFeedAPI(APIView): def get(self, request, format=None): feed = RokuContentFeed.objects.all().filter(is_public=True) serializer = RokuContentFeedSerializer(feed, many=True) return Response(serializer.data) ``` ``` class RokuContentFeedSerializer(serializers.ModelSerializer): providerName = serializers.CharField(source='provider_name') language = serializers.StringRelatedField() rating = RatingSerializerList() lastUpdated = serializers.DateTimeField(source='last_updated') movies = MovieSerializerList(many=True) liveFeeds = LiveFeedSerializerList(many=True, source='live_feeds') series = SeriesSerializerList(many=True) shortFormVideos = ShortFormVideoSerializerList(many=True, source='short_form_videos') tvSpecials = TVSpecialSerializerList(many=True, source='tv_specials') categories = CategorySerializerList(many=True) playlists = PlaylistSerializerList(many=True) class Meta: model = RokuContentFeed #read_only_fields = ['is_public'] fields = ['providerName', 'language', 'rating', 'lastUpdated', 'movies', \ 'liveFeeds', 'series', 'shortFormVideos', 'tvSpecials', 'categories', 'playlists'] ``` Thank for any suggestions AC -- You received this message because you are subscribed to the Google Groups "Django REST framework" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framework+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-rest-framework/56f7c360-4ac4-4229-b0bd-effbd68d9b37n%40googlegroups.com.
data.json
Description: application/json