How To Return A Json Object In Google Endpoints
The way I'm doing right now is I have a response class with a string message and return a json string. On the client side, I parse the string to use it as a object. I was wondering
Solution 1:
You can define 'message' and 'some_data' on the response class directly. eg:
class Response(messages.Message):
message = messages.StringField(1)
some_data = messages.StringField(2)
jsonDict = {"message": "success", "some_data": "data"}
return Response(**jsonDict )
If you only have a json string, you will need to convert to a dictionary first:
jsonDict = json.loads(jsonString)
Post a Comment for "How To Return A Json Object In Google Endpoints"