2016-12-22 8 views
0

こんにちは - 私は、私はGoogleのジオコーディングAPI要求から次の結果を得るには、次の構文AppleScriptをJSONフィールド抽出

tell application "JSON Helper" 
    set Resultado to (fetch JSON from Request) 
end tell 

を使用して

を返します。

{結果:{{formatted_address: "ショーグン博士カーメロ・ダゴスティーノ、628 - ジャルディンRincão、サンパウロ - SP、02991から040ブラジル"、partial_match:真、 address_components:{{SHORT_NAME {"street_number"}}、{short_name: "Rua Dr. Carmelo D'Agostino"、 long_name: "Rua Doutor Carmelo D'Agostino"タイプ:{"street_number"}}、 "long": "628"、 {short_name: "JardimRincão"、 "JardimRincão"、 タイプ:{"political"、 "sublocality_level_1"}}、 {short_name: "SãoPaulo"、long_name: "SãoPaulo"、 タイプ:{"administrative_area_level_2"、 "political"}}、{short_name: "SP"、{"country"、 "political"}} {{"}}} {{country}} {{country}} {{country}} {{country}} {{country} {"postal_code"}}}、 ジオメトリ:{ビューポート:{北東:{Lat:-23.432391219708、 、lng:-46.725645019708}、南西部: "02991-040"、ロングネーム: "02991-040"、 :{LAT:-23.435089180292、 LNG:-46.728342980292}}場所:{緯度:-23.4337402、LNG:-46.726994}、 LOCATION_TYPE: "ROOFTOP"}、place_id: "ChIJgVGzRqL7zpQRTQPNqsmBVLY"、 タイプ:{ "にstreet_address" }}}ステータス:「OK」}

私はちょうど返送メッセージに3回表示されます

02991から040

、フォーマットされたアドレスの一部として一度

formatted_address:ショーグン博士カーメロ "\ D'Agostino、628 - JardimRincão、 サンパウロ - SP、02991-040、ブラジル

二回郵便番号など

{SHORT_NAME: "02991から040"、LONG_NAME: "02991から040"、種類:{ "POSTAL_CODE"}私が過ごしてきた

かなり自分自身でそれを見つけることを試みる時間があるかもしれないが、私はハード/スマートに十分に試していない可能性がありますので、本当に任意のヘルプに感謝します。

ベスト

答えて

0

スクリプトは、抽出したい3つの値が含まれています三つの変数firstResultsecondResultthirdResultを持っています。

if Resultado's status is "OK" then 
    set theData to item 1 of results of Resultado 
    set formattedAddress to formatted_address of theData 
    set {TID, text item delimiters} to {text item delimiters, ", "} 
    set firstResult to text item 4 of formattedAddress 
    set text item delimiters to TID 
    set components to address_components of theData 
    tell last item of components 
     set secondResult to its long_name 
     set thirdResult to its short_name 
    end tell 
end if