简体   繁体   中英

ObjectMapper - writeValueAsString method converts object to null

I have this object:

dataToPost = {"input":{"key":"value"}}

when I process it at this line:

String data = mapper.writeValueAsString(dataToPost);

It returns the following:

{"input":"null"}

Why is it set to null? How to fix this?

要将jackson对象转换为String ,可以使用,

String data= dataToPost.toString();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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