JSR 311 実装として Jersey を使用しています。JSON に変換しようとしているオブジェクトは次のようになります。
@XmlRootElement
public class deliveryTimes{
private Integer id;
private Short type;
private Integer orderId;
/* ... more fields and autogenerated Getters & Setters ... */
}
JSON の結果は次のとおりです。
{"deliveryTimes":
[{"type":"1","orderId":"30449",/* ... other fields ... */ },
/* ... */
]}
つまり、フィールド「id」が失われています。私の他のオブジェクトでは、id フィールドには orderId、customerId などの他の名前があり、これらのフィールドは失われません。
私の pom.xml は次のようになります。
<!-- other stuff -->
<!-- JERSEY -->
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
<version>1.11</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-json</artifactId>
<version>1.11</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-grizzly2</artifactId>
<version>1.11</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-servlet</artifactId>
<version>1.11</version>
</dependency>
<!-- Jersey + Spring -->
<dependency>
<groupId>com.sun.jersey.contribs</groupId>
<artifactId>jersey-spring</artifactId>
<version>1.11</version>
<exclusions>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- other stuff -->
これ以上の構成はありません。ジャージのウェブサイトやグーグルで役立つ情報が見つからなかったので、初めての投稿でここにたどり着きました.
不足している構成オプションはありますか? IDフィールドをどのようにJSON化しますか?