【发布时间】:2018-06-07 06:07:10
【问题描述】:
我在我的 java-rest 中使用 com.fasterxml.jackson.databind.node.ObjectNode 来返回一个简单的值:
@POST
@Path ("/JsonApi")
@Consumes("application/json")
@Produces("application/json")
public ObjectNode postEmployee(JSONObject jsonObject)throws Exception{
String onlineUrl = MatafConfig.getConfigParam(request,
m_CONFIG_REDIRECT);
if(m_mapper == null)
m_mapper = new ObjectMapper();
ObjectNode jNode = m_mapper.createObjectNode();
jNode.put("url", onlineUrl); // debug shows {"url": "/mySite"}
//return url
return jNode;
}
jNode 中的值与预期的 {"url": "/mySite"} 一致,但在客户端显示其他 json -
{"nodeType":"OBJECT","valueNode":false,"containerNode":true,"missingNode":false,"array":false,"object":true,"pojo":false,"number":false,"integralNumber":false,"floatingPointNumber":false,"short":false,"int":false,"long":false,"float":false,"double":false,"bigDecimal":false,"bigInteger":false,"textual":false,"boolean":false,"null":false,"binary":false}
我不知道这个 json,我认为它可能是来自 jax-rs 的一些默认对象。
更多细节:java 8,jackson 2.6,使用 WebSphere 8.5 默认jax-rs libs。
【问题讨论】: