Cloud Endpoints Collection Parameter

后端 未结 2 732
萌比男神i
萌比男神i 2021-01-05 21:02

Im using Google App Engine Cloud Endpoints and Im trying to receive a collection parameter . Not sure if I can do this. I know I can return a List or any Collection.

相关标签:
2条回答
  • 2021-01-05 21:22

    Cloud Endpoints only deals with classes having the bean standard.

    So, I created a new class named ObjectListContainer:

    public class ObjectListContainer {
        public List<Object> getObjectsList() {
            return ObjectsList;
        }
        public void setObjectsList(List<Object> objectsList) {
            ObjectsList = objectsList;
        }
        private List<Object> ObjectsList;
    }
    

    Same problem if you are trying to return a String, you can't. You have to make a StringContainer.

    0 讨论(0)
  • 2021-01-05 21:26

    I have used a similar solution after think during long hours . Try this:

    public class JsonList<T> { 
    private List<T> listItens;
    
    public List<T> getListItens() {
        return listItens;
    }
    
    public void setListItens(List<T> listItens) {
        this.listItens = listItens;
    }}
    

    and in your method:

    @ApiMethod(
            name = "name",
            path = "path",
            httpMethod = ApiMethod.HttpMethod.POST)
    public CollectionResponse<Information> getInformation(JsonList<String> listOfItens) {}
    
    0 讨论(0)
提交回复
热议问题