0

このBingMapsJSONファイルがあり、その中から「++formattedAddress++」を取得したい

{
    "statusCode": 200,
    "statusDescription": "OK",
    "copyright": "Copyright © 2013 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.",
    "authenticationResultCode": "ValidCredentials",
    "resourceSets": [
        {
            "resources": [
                {
                    "__type": "Location:http://schemas.microsoft.com/search/local/ws/rest/v1",
                    "point": {
                        "type": "Point",
                        "coordinates": [
                            63.8185213804245,
                            12.105498909950256
                        ]
                    },
                    "matchCodes": [
                        "Good"
                    ],
                    "address": {
                        "addressLine": "55 Stuff",
                        "locality": "Stuff",
                        "++formattedAddress++": "55 Stuff, 51512 Stuff",
                        "postalCode": "25521",
                        "adminDistrict2": "Stuff-Stuff",
                        "countryRegion": "UK",
                        "adminDistrict": "NL"
                    },
                    "bbox": [
                        84.81465866285382,
                        12.097347537264563,
                        50.822384097995176,
                        7.11365028263595
                    ],
                    "name": "55 Stuff, 51122 Stuff",
                    "confidence": "Medium",
                    "entityType": "Address",
                    "geocodePoints": [
                        {
                            "calculationMethod": "Interpolation",
                            "type": "Point",
                            "usageTypes": [
                                "Display",
                                "Route"
                            ],
                            "coordinates": [
                                50.8185213804245,
                                7.105498909950256
                            ]
                        }
                    ]
                }
            ],
            "estimatedTotal": 1
        }
    ],
    "traceId": "8a13f73cab93472db1253e4c1621c651|BL2M002306|02.00.83.1900|BL2MSNVM001274, BL2MSNVM003152",
    "brandLogoUri": "http://dev.virtualearth.net/Branding/logo_powered_by.png"
}

私がこれまでに試したことは次のようなものです。

final JSONArray jsonMainArr = locationData.getJSONArray("resourceSets").getJSONObject(0).getJSONArray("resources");
final JSONObject childJSONObject = jsonMainArr.getJSONObject(0);
return childJSONObject.getString("formattedAddress");

childJSONObjectはformattedAddressよりも2〜3レベル上にあり、クエリは非常に非効率的になっています

4

2 に答える 2

3

現在の json String から FormattedAddress アドレス値を取得します。

final JSONObject childJSONObject = jsonMainArr.getJSONObject(0)
                                                .getJSONObject("address");
return childJSONObject.getString("++formattedAddress++");
于 2013-01-14T12:44:33.303 に答える
0

複雑なコードを貼り付けて、簡単な方法で入手できるオンライン サイトがたくさんあります。例http://json.parser.online.fr/

于 2013-01-14T12:51:26.253 に答える