私はjsonの解析に初心者です。要求からjsonの文字列を取得しましたが、今はjavaと解析する必要があります。私はjson-libを使っています。しかし、私はそれに精通していないので、私は本当に立ち往生しています。私はそのためのJavaコード以下の使用次のデータjsonとjavaを解析する
1. name (hotel name)
2. starRating
3. geoPoint
を抽出する必要があるが、それは私が必要とする結果を与えていない、誰かが...
おかげで多くのことを助けてください!
Javaコード(Sは私が手JSON文字列である)私は、任意のJSONオブジェクトがMap<String, Object>
として表すことができ
[
{
"total": 250,
"offset": 0,
"requestID": "-btygi09oxfov",
"locationName": "Paris, France",
"locationLatitude": 48.86,
"locationLongitude": 2.34,
"cityCode": "PARIS_J_FR",
"hotels": [
{
"ypid": "YN10001x300073304",
"id": 56263,
"hotelRateIndicator": "2",
"name": "Renaissance Paris Vendome Hotel",
"brandCode": "69",
"addressLine1": "4 Rue du Mont-Thabor",
"city": "Paris",
"neighborhood": "",
"state": "IdF",
"country": "US",
"cachedPrice": 935,
"geoPoint": [
48.865361,
2.329584
],
"starRating": "5",
"thumbnailUrl": "http://www.orbitz.com//public/hotelthumbnails/53/97/85397/85397_TBNL_1246535840051.jpg",
"total": 250,
"amenities": [
"24",
"31",
"42",
"52",
"9"
],
"telephoneNumbers": [
""
],
"popularity": 837
},
{
"ypid": "YN10001x300073331",
"id": 112341,
"hotelRateIndicator": "3",
"name": "Renaissance Paris Arc de Triomphe Hotel",
"brandCode": "69",
"addressLine1": "39 Avenue de Wagram",
"city": "Paris",
"neighborhood": "",
"state": "IdF",
"country": "US",
"cachedPrice": 633,
"geoPoint": [
48.877107,
2.297451
],
"starRating": "5",
"thumbnailUrl": "http://www.orbitz.com//public/hotelthumbnails/21/72/302172/302172_TBNL_1246535872514.jpg",
"total": 250,
"amenities": [
"24",
"31",
"42",
"9"
],
"telephoneNumbers": [
""
],
"popularity": 796
}
]
}
]
:
ここでは、リンクのですか?エラーが発生していますか?または、必要なデータを取得していないか? – aldrin
@adrin:スレッド「main」の例外が発生するjava.lang.ClassCastException:net.sf.json.JSONArrayをnet.sf.json.JSONObjectにキャストすることはできません –