سؤال

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?

هل كانت مفيدة؟

المحلول

Use a repeated field:

class Response(messages.Message):
    items = messages.StringField(1, repeated=True)
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top