Trying to parse a Json with Open Refine GREL

你说的曾经没有我的故事 提交于 2019-12-06 07:03:55

问题


I'm trying to parse this JSON but really can't find the way to extract the data I want.

{ "results" :
    [ { "address_components" :
        [
            { "long_name" : "44", "short_name" : "44", "types" : [ "street_number" ] },
            { "long_name" : "Rue Montaigne", "short_name" : "Rue Montaigne", "types" : [ "route" ] },
            { "long_name" : "Agen", "short_name" : "Agen", "types" : [ "locality", "political" ] },
            { "long_name" : "Lot-et-Garonne", "short_name" : "Lot-et-Garonne", "types" : [ "administrative_area_level_2", "political" ] },
            { "long_name" : "Aquitaine", "short_name" : "Aquitaine", "types" : [ "administrative_area_level_1", "political" ] },
            { "long_name" : "France", "short_name" : "FR", "types" : [ "country", "political" ] },
            { "long_name" : "47000", "short_name" : "47000", "types" : [ "postal_code" ] }
        ],
        "formatted_address" : "44 Rue Montaigne, 47000 Agen, France",
        "geometry" : {
            "bounds" : {
                "northeast" : { "lat" : 44.1994907, "lng" : 0.6172573 },
                "southwest" : { "lat" : 44.19949039999999, "lng" : 0.6172388999999999 }
            },
            "location" : { "lat" : 44.19949039999999, "lng" : 0.6172573 },
            "location_type" : "RANGE_INTERPOLATED",
            "viewport" : {
                "northeast" : { "lat" : 44.20083953029149, "lng" : 0.618597080291502 },
                "southwest" : { "lat" : 44.1981415697085, "lng" : 0.6158991197084979 }
            }
        },
        "partial_match" : true,
        "types" : [ "street_address" ]
    } ],
"status" : "OK" }

I'm trying to isolate the lat and the lng from the point I geolocalized with Google Refine GREL ("location" : { "lat" : 44.19949039999999, "lng" : 0.6172573 }).

Can you give me a hint of what I should do to succeed?


回答1:


Try this:

with(value.parseJson().results[0].geometry.location, pair, pair.lat +", " + pair.lng)


来源:https://stackoverflow.com/questions/18444834/trying-to-parse-a-json-with-open-refine-grel

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!