My JSON file : (It's a file)
{ "user-id": 10009, "rating": 3, "movie_id": 9823 }
I need to get the each data separately.so I can store them in database. the JSON file is a form-data.
I tried:
def post(self, request):
data = request.FILES['json_file']
# a = data.read().decode('utf-8')
a = json.loads(data)
x = a['user-id']
print(x)
return Response(x, status=status.HTTP_201_CREATED)
The above code is not working and giving me error:
the JSON object must be str, not 'InMemoryUploadedFile'
How can i get data from JSON file(form-data) and store it's content in database?