English 中文(简体)
Jackson JAXB 支持军团在物体内物体
原标题:Jackson JAXB support doesnt marshall objects inside objects?

我对Jacksons JAXB的支持感到困惑不解,似乎没有把物体射入其他物体?

这是我的法典(简化、不接收/设定):

@XmlRootElement( name = "identifiableObject" )
class IdentifiableObject {
  @XmlAttribute
  Integer id;

  @XmlElement
  String name;
}

@XmlRootElement( name = "a" )
class A extends IdentifiableObject {}

@XmlRootElement( name = "b" )
class B extends IdentifiableObject {
  @XmlElement
  @XmlJavaType( IdentifiableObjectXmlAdapter.class )
  A a;
}

当我利用日本宇宙航空研究开发机构进行演习时,它会进行罚款。 但是,当我试图与Jackson合议时,似乎只看到该物体的直接说明,这样它就意味着:

{ id: 1,   name: "name",   a: {} }

如果我添加<条码>@JsonProperty,以备我的证明 反对是有效的,但我希望不要这样做。 如果是,它似乎喜欢@XmlJavaAdapter。 越演越烈(并非如此奇怪),因为我有<条码>。

任何途径:

(a) 贝尔赫斯 日本宇宙航空研究开发机构支持对物体进行深造吗? (如上所述,与JacksonAnnotation Introspector合著)

(b) 是否对Jackson有类似于XmlAdapter的、我可以插手吗?

UPDATE: To clarify, my expected output was:

{
  id: 1,
  name: "b object",
  a: {
    id: 2, 
    name: "a object"
  }
}

这是在利用日本宇宙航空研究开发机构进行军事训练时的缺席行为,但在为日本人(通过日本宇宙航空研究开发机构通知探测器)采取同样行动的时候。

(a) 我目前的解决办法是增加<条码>@JsonProperty。 仅仅就在任何地方,这样,劫持者通知就会被人使用(因为我是我的双亲,是主要的探测器),而该信是科索沃的,但我却对每一天都有这么多的说明。

(b) 我在此尝试使用以下惯例:<条码>@JsonSerialize,但即使我在此将物体降为<条码>(目标)a;它仍然“见”旧版本的,并 everything弄其中的一切。

-- Morten

问题回答

暂无回答




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签