How to convert JSON to protocol buffer in django rest framework

Submitted 2 years, 8 months ago
Ticket #435
Views 500
Language/Framework Django
Priority Medium
Status In-Progress

I am trying to create an api which get an json input and convert it into the protocol buffer,but getting error

Parse() missing 1 required positional argument: 'message

here is the api
 

class Proto(APIView):

def get(self, request, *args, **kwargs):

try:

data={

"name": "Ashutosh",

"age": "26",

"city": "gurgaon",

"phone_number": "9717336958"

}

data = str(data)

parsed_data = json.dumps(ast.literal_eval(data))

#message = Parse(json.dumps(parsed_data))

a = google.protobuf.json_format.Parse(parsed_data)

return Response({'status':'SUCCESS','data':"pending...."},status=200)

except Exception as e:

return Response({'status':'ERROR','message':str(e)})

Submitted on Sep 07, 21

is this addresses? - Vengat 2 years, 6 months ago
add a comment


Latest Blogs