残りのサービスは次のように応答します
<transaction><trxNumber>1243654</trxNumber><type>INVOICE</type></transaction>
またはJSONで:
{"transaction":{"trxNumber":1243654,"type":"INVOICE"}}
私が使用しても問題はありません:
mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true)
そして結果のクラスとして
@JsonRootName("transaction")
public class Transaction {
private String trxNumber;
private String type;
//getters and setters
}
しかし、実際には、サードパーティの jar の Transaction クラスを使用する必要があります。これは上記とまったく同じですが、 @JsonRootName("transaction") 注釈はありません。
だから私はで終わる
Could not read JSON: Root name 'transaction' does not match expected ('Transaction') for type...
Transaction クラス自体に何かを追加せずに Jackson 解析を Transaction クラスに強制する方法はありますか (このファイルをバイナリ jar の一部として取得するため)。
カスタムの PropertyNamingStrategy を試してみましたが、フィールド名とゲッター/セッター名のみに関係しているようで、クラス名には関係ないようです。
Java7、ジャクソン 2.0.5。
助言がありますか?ありがとう。