简体   繁体   English

Fasterxml Jackson ObjectMapper生成带有'='字符的JSON字符串

[英]Fasterxml Jackson ObjectMapper produces JSON string with '=' character

This question refers to Java library com.fasterxml.jackson.core:jackson-databind:2.8.8 ( jackson-databind-2.8.8.jar ) 这个问题是指Java库com.fasterxml.jackson.core:jackson-databind:2.8.8jackson-databind-2.8.8.jar

Given object is a POJO with: 给定object是具有以下内容的POJO:

@com.fasterxml.jackson.annotation.JsonRawValue
private Map<String, String> innerDetail = new HashMap<String, String>();

innerDetail.put("Auth", "{\"node\":\"VALUE\"}");

(The POJO is also annotated with com.fasterxml.jackson.annotation.JsonInclude ) (POJO还使用com.fasterxml.jackson.annotation.JsonInclude注释)

Then calling: 然后调用:

com.fasterxml.jackson.databind.ObjectMapper.writeValueAsString(object)

Returns a String containing: 返回一个包含以下内容的String

"innerDetail":{Auth={"node":"VALUE"}

Surely the = (equals) should be a : (colon)? = (等于)肯定应该是:冒号)吗?

I don't see that = is any part of JSON syntax. 我看不到=是JSON语法的任何部分。

It's due to your use of @JsonRawValue . 这是因为您使用了@JsonRawValue The JavaDoc for it says JavaDoc

...Warning: the resulting JSON stream may be invalid depending on your input value. ...警告:根据您输入的值,生成的JSON流可能无效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM