JSONの次のPOJOクラスを作成する必要があります。問題はキーp_dにs_t、n_t、n_pなどの動的名を持つ変数があります。実際のJSONは大きくてその部分の問題に直面して、私は部分JSONを共有しました。 私はjacksonを解析に使用しています。動的キーと値のペアのJSONからJAVA POJO
動的なキーについては{
"flag": true,
"flag2": false,
"r_no": [
{
"room_type": 250067,
"no_of_rooms": 1,
"no_of_children": 1,
"no_of_adults": 2,
"description": "Executive Room, 1 King Bed, Non Smoking",
"children_ages": [
8
]
},
{
"room_type": 250067,
"no_of_rooms": 1,
"no_of_children": 0,
"no_of_adults": 2,
"description": "Executive Room, 1 King Bed, Non Smoking"
}
],
"r_code": "abc",
"r_key": "123",
"p_d": {
"s_t": [
{
"name": "xyz",
"cur": "INR"
},
{
"name": "xyz1",
"cur": "INR"
}
],
"n_t": [
{
"name": "xyz2",
"cur": "INR"
}
],
"n_p": [
{
"name": "xyz5",
"cur": "INR"
}
]
},
"cur": "INR"
}
どこのtryコードはありますか? @Suraj –
パブリッククラスPD { @JsonProperty( "s_t") 民間一覧 ST =新しいArrayListを(); @JsonProperty( "n_t") プライベートリスト nT = new ArrayList (); @JsonProperty( "n_p") プライベートリスト nP = new ArrayList (); @JsonIgnore プライベートマップ additionalProperties = new HashMap (); setter getter} –
Suraj
ここでは変数名は静的ですが、動的変数が必要です。 – Suraj