与序列化和布尔类型反序列化JSON提供杰克逊问题 [英] JSON provider jackson issues with serializing and deserializing with Boolean type

查看:673
本文介绍了与序列化和布尔类型反序列化JSON提供杰克逊问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须使用布尔包装和JSON对象,当布尔创建JSON对象值它含有例如字符串柯特斯问题isUrgent:1现在问题是,我每次都手动把它包在我的code为每个请求/响应

I have a problem using Boolean wrapper with JSON Object, when JSON object is created for Boolean values it contain string cotes for example "isUrgent" : "1" Now the issue is I have to wrap it manually in my code each time for each request/response

任何机构可以请提供我上述问题的永久解决方案?

Can any body please provide me a permanent solution for above problem?

推荐答案

解决方案是定制解串器的布尔类型。所有你需要做的就是添加额外的解串器它可以处理,你的目标是反序列化的布尔特定字符串值的情况。

The solution is to customize the deserializer for the boolean type. All you need to do is add extra deserializer which could handle the case of particular String values which you aim to deserialize as the booleans.

继博客文章解释得很详细。

Following blog post explains it in detail.

<一个href=\"http://hussainpithawala.word$p$pss.com/2011/05/11/overriding-default-serializationdeserialization-behaviour-of-jackson-json-serializer/\" rel=\"nofollow\">http://hussainpithawala.word$p$pss.com/2011/05/11/overriding-default-serializationdeserialization-behaviour-of-jackson-json-serializer/

这篇关于与序列化和布尔类型反序列化JSON提供杰克逊问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆