在消息中发送类字段元数据

时间:2012-11-27 10:51:38

标签: java json reflection jackson meta

有没有人在jackson JSON遇到过这个问题 - 不知怎的,JSON包含了我的每个类字段类型,以及我不感兴趣的其他元数据,因此发送的数据是巨大的!

E.g。这是一条记录:

{
    "queue": "H",
    "internalStatus": "New",
    "id": "50030386",
    "screenDescription": "Test Case 1",

}
},
"fields": [
{
    "name": "id",
    "type": "java.lang.Integer",
    "modifiers": 2,
    "annotations": [

    ],
    "declaredAnnotations": [

    ],
    "declaringClass": "com.me.Charge",
    "synthetic": false,
    "genericType": "java.lang.Integer",
    "enumConstant": false,
    "accessible": false
},
{
    "name": "screenDescription",
    "type": "java.lang.String",
    "modifiers": 2,
    "annotations": [

    ],
    "declaredAnnotations": [

    ],
    "declaringClass": "com.me.Charge",
    "synthetic": false,
    "genericType": "java.lang.String",
    "enumConstant": false,
    "accessible": false
},
{
    "name": "internalStatus",
    "type": "java.lang.String",
    "modifiers": 2,
    "annotations": [

    ],
    "declaredAnnotations": [

    ],
    "declaringClass": "com.me.Charge",
    "synthetic": false,
    "genericType": "java.lang.String",
    "enumConstant": false,
    "accessible": false
},
{
    "name": "queue",
    "type": "java.lang.String",
    "modifiers": 2,
    "annotations": [

    ],
    "declaredAnnotations": [

    ],
    "declaringClass": "com.me.Charge",
    "synthetic": false,
    "genericType": "java.lang.String",
    "enumConstant": false,
    "accessible": false
},

感谢任何帮助。

谢谢, 斯蒂芬

1 个答案:

答案 0 :(得分:0)

检查代码以进行设置

objectMapper.enableDefaultTyping(...)

有些价值......