在我的解决方案中,我实现了一个java客户端,它使用了使用JSONAPIDOTNETCORE实现的REST API。
这是调用REST API的Java代码片段
response = client
.resource(
CreateURLWithFilters(API_BASE_URL,
"?page[size]=100&filter[endDate]=ge:"))
.accept("application/json")
.type("application/vnd.api+json")
.header(HttpHeaders.AUTHORIZATION, "Bearer " + token)
.get(ClientResponse.class);
我正在使用JSON API支持的过滤器查询参数来获得所需的行为。
我希望JSON API过滤空值。例如
"?page[size]=100&filter[endDate]=eq:null"
不确定JSONAPIDOTNET核心库是否支持此类操作。或者我们可以在jsonapidotnet核心库中实现对空值的过滤。
例如,查询没有过滤器参数的JSONAPI会给我这个结果
[{"attributes":{"endDate":"2018-05-31T00:00:00","id":2,"priority":1,"message":"testing today ","propertyId":1,"roomId":null,"startDate":"2018-05-16T00:00:00","dateModifiedUtc":"2018-05-16T10:58:42.493"},"id":"2","type":"notices"}]
我想只过滤enddate为null的那些
[{"attributes":{"endDate":null,"id":1,"priority":1,"message":"wrewr","propertyId":1,"roomId":null,"startDate":"2018-05-16T00:00:00","dateModifiedUtc":"2018-05-16T10:38:22.727"},"id":"1","type":"notices"}