Question

I want to return a json output in GAE endpoints. How can I do it with messages.

{
    "items": [
        1: { ... }
        2: { ... }
        ...
    ]
}

e.g.

class Response(messages.Message):
    items = messages.StringField(1)

produces output

{
   "items": "message content"
}

How can I return an array for items?

Was it helpful?

Solution

Use a repeated field:

class Response(messages.Message):
    items = messages.StringField(1, repeated=True)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top