問題:從JSON文件中提取數據並將其存儲在Java中以進行調用的方法。使用Java從JSON中提取數據
什麼我試圖做的事:我想提取從JSON文件中的數據產生使用Java屏幕上的數據進行比較。
我已經試過:所有我試圖找到從JSON文件中提取的數據資源和信息,但隨後試圖通過操縱手文本做的第一,但這顯然不是可伸縮的。
守則
{
"searchRoutes":
{
"0": "refinements"
}
"searchResults":
{
"classifiedAdverts":
{
"0":
{
"id": "201401311453322"
"capId": "20524"
"channel": "cars"
"distanceFromVehicleLocation": 0
"searchTarget": "usedcars"
"advertAttributes":
{
"advertTitle": "Ford Fiesta 1.3 Flight 3dr +PX TO CLEAR+NO MOT-TAX+"
"description": "RED, 07989 715714, Tilt/removable glass sunroof, 14" 7 spoke alloy wheels, Central locking, Stereo radio/cassette model 3000NT/2 speakers, Immobiliser-Passive Anti-Theft System (PATS), Driver's seat manual height adjustment. £195 p/x welcome"
"advertVersionNumber": 7
"advertPlacementDate": 20140131152126
"advertPlacementDateFormatted": "31/01/2014 15:21:26"
"daysOld": 6
"isBasicAdvert": "false"
"displayAdvertiserAddress": "true"
"vehicleLatLong":
{
"0": 52.501497
"1": -1.832014
}
"town":
{
"county":
{
"region":
{
"numberOfAdverts": 0
"name": "WEST MIDLANDS"
}
"numberOfAdverts": 0
"name": "WEST MIDLANDS"
}
"numberOfAdverts": 0
"name": "BIRMINGHAM"
}
"isTrade": "true"
"isNearlyNew": "false"
"isUsedApproved": "false"
"partExchangeAllowed": "false"
"price": 195
"vehiclePriceExtra": "p/x welcome"
"telesafe": "false"
"badAdType": "OK"
"oneSearchAds": "used"
"displaySlideShow": "false"
"videoAudioDisabled": "true"
"imageInfo":
{
"imageDimensions":
{
"width": "1024"
"height": "768"
}
"advertImages":
{
"0":
{
"imageId": "3fb3f6858942f51ace201b490b953180"
"imageUrlTemplate": "http://pictures2.autotrader.co.uk/imgser-uk/imgser-uk/servlet/media?id=3fb3f6858942f51ace201b490b953180&width={width}&height={height}"
}
"1":
{
"imageId": "5cf02458c4142e9049166548015b9714"
"imageUrlTemplate": "http://pictures2.autotrader.co.uk/imgser-uk/imgser-uk/servlet/media?id=5cf02458c4142e9049166548015b9714&width={width}&height={height}"
}
}
}
"owners": 4
}
"advertiserAttributes":
{
"name": "Parkway West Midland"
"phoneNumber1":
{
"formattedPhoneNumber": "(0121) 3278777"
"shouldAddAsteriskIfIsCallTrackerNumber": "false"
}
"phoneNumber2":
{
"formattedPhoneNumber": "(0121) 3286744"
"shouldAddAsteriskIfIsCallTrackerNumber": "false"
}
"alternativePhoneNumber":
{
"formattedPhoneNumber": "(0121) 3278777"
"shouldAddAsteriskIfIsCallTrackerNumber": "false"
}
"email": "[email protected]"
"emailLink": "/redirect-email/advert/201401311453322/postcode/b82sl"
"address1": "186b Drews Lane"
"postcode": "B8 2SL"
"town": "Birmingham"
"county": "West Midlands"
}
"vehicleAttributes":
{
"make": "FORD"
"model": "FIESTA"
"yearOfManufacture": "2001"
"regLetter": "51"
"transmission": "Manual"
"fuelType": "Petrol"
"bodyType": "Hatchback"
"mileage": "105000"
"engineSize": "1300"
"derivative": "1.3 FLIGHT 3DR"
"colour": "Red"
"numDoors": "3 doors"
"vrm": "DV51LTZ"
"generationId": 11015
"vehicleRegistrationDate": "2001-10-29"
"quickQuoteInsuranceGroup": 6
"vehicleMileageUnit": "M"
"totalUserReviews": 254
"userReviewRating": 414
"vehicleCheck": "false"
"co2Emissions": 171
}
"dealerAttributes":
{
"id": "490131"
"name": "Parkway West Midland"
"email": "[email protected]"
"address1": "186b Drews Lane"
"postcode": "B8 2SL"
"town": "Birmingham"
"logoUrl": "http://dealerlogo.autotrader.co.uk/at2/adbranding/490131/images/searchlogo.gif"
"websiteLink": "http://dmsgateway.autotrader.co.uk/api/advertiser/490131/redirect/advert/source/autotrader-desktop/autotrader-advert/201401311453322?website-link=http%3A%2F%2Fwww.parkwaybirmingham.co.uk"
"oldDealerStockFlag": "N"
"stockCount": 95
"products":
{
"0": "videoSlideShow"
"1": "razsorMobile"
"2": "carDealerStockView"
"3": "associatedVehiclesCars"
"4": "razsorEnhancedWebsite"
"5": "standOutCars"
}
"additionalLinks": ""
"promotionBullets": ""
"backgroundColourBikes": "Blue"
"backgroundColourCars": "Blue"
"brandingImage": "header.jpg"
"addressDisplayable": "true"
"franchises": ""
"structuredLocation":
{
"county":
{
"region":
{
"numberOfAdverts": 0
"name": "WEST MIDLANDS"
}
"numberOfAdverts": 0
"name": "WEST MIDLANDS"
}
"numberOfAdverts": 0
"name": "BIRMINGHAM"
}
"mobileWebsiteLink": "http://dmsgateway.autotrader.co.uk/api/advertiser/490131/redirect/advert/source/autotrader-desktop/autotrader-advert/201401311453322?website-link=http%3A%2F%2Fwww.parkwaybirmingham.co.uk"
"numberOfReviews": "null"
}
"capTechSpecFlag": "Y"
}
}
"totalResults": 2118
}
"paginator":
{
"currentPage": 1
"totalResults": 2118
"pageSet":
{
"0":
{
"displayName": "1"
"value": "1"
"selected": "true"
"link": "http://sss.gen.tradermedia.net/sss/classified-adverts?Make=FORD&Model=Fiesta&Colour=Red&Page_Size=1&Page_Number=1"
}
"1":
{
"displayName": "2"
"value": "2"
"selected": "false"
"link": "http://sss.gen.tradermedia.net/sss/classified-adverts?Make=FORD&Model=Fiesta&Colour=Red&Page_Size=1&Page_Number=2"
}
"2":
{
"displayName": "3"
"value": "3"
"selected": "false"
"link": "http://sss.gen.tradermedia.net/sss/classified-adverts?Make=FORD&Model=Fiesta&Colour=Red&Page_Size=1&Page_Number=3"
}
"3":
{
"displayName": "First"
"value": "1"
"selected": "true"
"link": "http://sss.gen.tradermedia.net/sss/classified-adverts?Make=FORD&Model=Fiesta&Colour=Red&Page_Size=1&Page_Number=1"
}
"4":
{
"displayName": "Next"
"value": "2"
"selected": "false"
"link": "http://sss.gen.tradermedia.net/sss/classified-adverts?Make=FORD&Model=Fiesta&Colour=Red&Page_Size=1&Page_Number=2"
}
"5":
{
"displayName": "Last"
"value": "2118"
"selected": "false"
"link": "http://sss.gen.tradermedia.net/sss/classified-adverts?Make=FORD&Model=Fiesta&Colour=Red&Page_Size=1&Page_Number=2118"
}
}
"resultsPerPage": 1
}
"sortOrderInfo":
{
"0":
{
"Sort_Key": "Price"
"Sort_Order": "Asc"
}
"1":
{
"Sort_Key": "Price"
"Sort_Order": "Desc"
}
"2":
{
"Sort_Key": "Make"
"Sort_Order": "Asc"
}
"3":
{
"Sort_Key": "Model"
"Sort_Order": "Asc"
}
"4":
{
"Sort_Key": "Mileage"
"Sort_Order": "Asc"
}
"5":
{
"Sort_Key": "PaidFor"
"Sort_Order": "Desc"
}
"6":
{
"Sort_Key": "DealerName"
"Sort_Order": "Asc"
}
"7":
{
"Sort_Key": "DealerName"
"Sort_Order": "Desc"
}
"8":
{
"Sort_Key": "Distance"
"Sort_Order": "Asc"
}
"9":
{
"Sort_Key": "Age"
"Sort_Order": "Asc"
}
"10":
{
"Sort_Key": "Age"
"Sort_Order": "Desc"
}
"11":
{
"Sort_Key": "PlacementDate"
"Sort_Order": "Asc"
}
"12":
{
"Sort_Key": "PlacementDate"
"Sort_Order": "Desc"
}
"13":
{
"Sort_Key": "LocationPrice"
"Sort_Order": "Asc"
}
"14":
{
"Sort_Key": "AgePrice"
"Sort_Order": "Asc"
}
"15":
{
"Sort_Key": "MileagePrice"
"Sort_Order": "Asc"
}
}
"requestInfo":
{
"base-path": "http://sss.gen.tradermedia.net/sss"
"image-base-path": "http://pictures2.autotrader.co.uk"
"editorial-image-base-path": "http://www.autotrader.co.uk"
"request-url": "http://sss.gen.tradermedia.net/sss/classified-adverts?Make=FORD&Model=Fiesta&Colour=Red&Page_Size=1"
}
}
感謝你的幫助球員,我需要在低位包括,只是發表評論的任何改變或事物。
使用gson。 https://code.google.com/p/google-gson/ –
或flexjson(這也很好) – Leo
布拉德利,你可以分享你從哪裏獲取API提要,我正在尋找你看到的那個提要,但我似乎無法在任何地方找到它。 – dearsina