Question

I have this Request class that I am using in Robospice and the Google HTTP Java client:

public class MyRequest {
    @Key
    private List<String> Items;
 //.....
}

Which I use:

MyRequest myRequest = new MyRequest();
myRequest.setItems(data);

this.postMyRequest = new PostMyRequest(myRequest);
getSpiceManager().execute(postMyRequest, new PostMyRequestListener());

and

JsonHttpContent jsonHttpContent = new JsonHttpContent(new JacksonFactory(), this.myRequest);

HttpRequest httpRequest = getHttpRequestFactory()
            .buildPostRequest(new GenericUrl(this.baseUrl), jsonHttpContent);
httpRequest.setParser(new JacksonFactory().createJsonObjectParser());

Response response = httpRequest.execute().parseAs(getResultType());

How to I change the root array name (from "Items") to somethings else? I have tried @JsonProperty("Foo") but that didn't do anything.

Was it helpful?

Solution

OK, figured it out.

I extended my class from an ArrayList instead.

public class MyRequest extends ArrayList<String> {
 //.....
}

That made the root name blank/empty (Which is what I wanted anyway)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top