python客户端发送和数组,如
"data": {"RPT_CC1_PHASE_MECH_TOT": [[1481625735000.0, NaN, 3.0], [1481625795000.0, NaN, 3.0], [1481625855000.0, NaN, 3.0], [1481625915000.0, NaN, 3.0]
而apache无法解析
2016-12-14 11:35:06,666 [http-nio-9092-exec-3] WARN WebApplicationExceptionMapper - javax.ws.rs.InternalServerErrorException: org.codehaus.jackson.JsonParseException: Non-standard token 'NaN': enable JsonParser.Feature.ALLOW_NON_NUMERIC_NUMBERS to allow
at [Source: org.apache.cxf.transport.http.AbstractHTTPDestination$1@241e15da; line: 1, column: 401]
at org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.processRequest(JAXRSInInterceptor.java:242)
at org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.handleMessage(JAXRSInInterceptor.java:98)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:271)
如何在APACHE?上启用此特性
这个似乎不起作用
jsonFactory.configure(JsonParser.Feature.ALLOW_NON_NUMERIC_NUMBERS, true);
发布于 2016-12-14 12:45:38
我自己发现:
在spring上配置自定义提供程序
<jaxrs:providers>
<bean class="my.service.ApplicationJSONProvider" />
</jaxrs:providers>
然后
public class ApplicationJSONProvider extends JacksonJsonProvider {
private static ObjectMapper mapper = new ObjectMapper();
public ApplicationJSONProvider() {
super(mapper, BASIC_ANNOTATIONS);
mapper.configure(Feature.ALLOW_NON_NUMERIC_NUMBERS, true);
https://stackoverflow.com/questions/41142683
复制相似问题