How to return an array response in Google App Engine endpoints
-
22-12-2019 - |
سؤال
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)
لا تنتمي إلى StackOverflow