我正在尝试发送一个 POST 请求,其形式为:
{
"startTime":"2014-12-02T00:00:00.000Z",
"endTime":"2014-12-03T00:00:00.000Z",
"numRows":200,
"object":{
"key":"I am having trouble parsing you",
"key2":"value2"
}
}
在后端(使用 dropwizard),我的资源类定义为:
class ResourceExample{
public Response process(SearchQuery q){
//doing something
//here q.object = {} instead of {"key": "I am having trouble parsing you", "key2" : "value2"}
}
}
class SearchQuery{
@NotNull
JSONObject object;
@NotNull
String startTime;
@NotNull
String endTime;
@NotNull
int numRows;
//getters and setters present.
}
现在,当我发布请求时,“object”的值为 {}。我希望它是 {"key": "I am hard to parsing you", "key2": "value2" }
请在这里帮助我。我确信我缺少一些东西。一些在我脑海中没有点击的东西。我哪里错了?