最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

jsonpath - Filtering list of string with Json Path - Stack Overflow

programmeradmin8浏览0评论

I have the following json example

{
    "address_components": [
        {
            "long_name": "43a",
            "short_name": "43a",
            "types": [
                "street_number"
            ]
        },
        {
            "long_name": "South Audley Street",
            "short_name": "S Audley St",
            "types": [
                "route"
            ]
        },
        {
            "long_name": "London",
            "short_name": "London",
            "types": [
                "postal_town"
            ]
        },
        {
            "long_name": "Greater London",
            "short_name": "Greater London",
            "types": [
                "administrative_area_level_2",
                "political"
            ]
        },
        {
            "long_name": "England",
            "short_name": "England",
            "types": [
                "administrative_area_level_1",
                "political"
            ]
        },
        {
            "long_name": "United Kingdom",
            "short_name": "GB",
            "types": [
                "country",
                "political"
            ]
        },
        {
            "long_name": "W1K 2PU",
            "short_name": "W1K 2PU",
            "types": [
                "postal_code"
            ]
        }
    ]
}

which is a subset of the response obtained querying the Google Geocoding service as described here

I would like to apply a couple of json path queries to be able to rebuild the address components elements into a multiline string like the following

43a S Audley St
London W1K 2PU
United Kingdom

Based on these answers #1, #2, I know I am able to apply filtering and expressions. Also, based on this page, I've learned that I can use the in operator to filter on the types attribute.

However all my attempts did not succeded. Any help?

发布评论

评论列表(0)

  1. 暂无评论