2016-03-29 19 views
-2

[{"statusCode":200,"body":null,"string":"{\"authenticationResultCode\":\"ValidCredentials\",\"brandLogoUri\":\"http:\\\/\\\/dev.virtualearth.net\\\/Branding\\\/logo_powered_by.png\",\"copyright\":\"Copyright © 2016 Microsoft and its suppliers. All rights reserved. This API cannot be accessed and the content and any results may not be used, reproduced or transmitted in any manner without express written permission from Microsoft Corporation.\",\"resourceSets\":[{\"estimatedTotal\":1,\"resources\":[{\"__type\":\"Location:http:\\\/\\\/schemas.microsoft.com\\\/search\\\/local\\\/ws\\\/rest\\\/v1\",\"bbox\":[38.251775282429321,-85.764416391531825,38.259500717570674,-85.751299608468173],\"name\":\"425 W Market St, Louisville, KY 40202\",\"point\":{\"type\":\"Point\",\"coordinates\":[38.255638,-85.757858]},\"address\":{\"addressLine\":\"425 W Market St\",\"adminDistrict\":\"KY\",\"adminDistrict2\":\"Jefferson Co.\",\"countryRegion\":\"United States\",\"formattedAddress\":\"425 W Market St, Louisville, KY 40202\",\"locality\":\"Louisville\",\"postalCode\":\"40202\"},\"confidence\":\"High\",\"entityType\":\"Address\",\"geocodePoints\":[{\"type\":\"Point\",\"coordinates\":[38.255638,-85.757858],\"calculationMethod\":\"Parcel\",\"usageTypes\":[\"Display\"]},{\"type\":\"Point\",\"coordinates\":[38.255367279052734,-85.757896423339844],\"calculationMethod\":\"Interpolation\",\"usageTypes\":[\"Display\",\"Route\"]}],\"matchCodes\":[\"Good\"]}]}],\"statusCode\":200,\"statusDescription\":\"OK\",\"traceId\":\"6bcd334413524cdba8d5c58e85cc1028|HK20271556|02.00.153.400|HK2SCH010280724, HK2SCH010310229\"}"}]從java獲得值使用java的字符串

這是我的Input,它是字符串格式的單行值。
需要獲取裏面的所有值(resourceSets標籤) 如何獲得這些值?

回答

0

試用Gson library ...從Json和POJO的方法都是你需要的。

0

您可以隨時使用ObjectMapper(傑克遜庫)並將其映射到適合於您發送或使用番石榴庫的JSON一個POJO(檢查:JSON parsing using Gson for Java