How to deserialize a blank JSON string value to null for java.lang.String?

前端 未结 6 1431
既然无缘
既然无缘 2020-12-01 16:10

I am trying a simple JSON to de-serialize in to java object. I am however, getting empty String values for java.lang.String property values. In rest of

6条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-01 16:38

    A simple work around would be to replace "" with null before deserializing the json string.

    .replace("\"\"", "null")

    This way all blank string will be deserialized as null

提交回复
热议问题