使用 AppleScript 和 JSON 解析数据时出错

Error parsing data with AppleScript and JSON

你好, 我正在尝试使用 appleScriptJSON 助手解析一些数据,
专门尝试获取 image 属性.

src 的值
 tell application "JSON Helper"
    -- fetch the JSON
    set wallpaperJson to fetch JSON from "https://glowing-torch-5096.firebaseio.com//kimono/api/95cifi2g/latest.json"

    -- pull out the URL
    set wallpaperUrl to src of image of model of results of wallpaperJson

结果,

error "Can’t get image of {{image:{alt:\"April by Rich Cutrone on 500px\", src:\"https://drscdn.500px.org/photo/141047085/q%3D80_h%3D300/fa5a7f61529d6e30a31c04edc63ccdec\"}}}." number -1728 from image of {{image:{alt:"April by Rich Cutrone on 500px", src:"https://drscdn.500px.org/photo/141047085/q%3D80_h%3D300/fa5a7f61529d6e30a31c04edc63ccdec"}}}

来源JSON:

{"count":1,"lastrunstatus":"success","name":"500HDPic","newdata":true,"results":{"model":[{"image":{"alt":"April by Rich Cutrone on 500px","src":"https://drscdn.500px.org/photo/141047085/q%3D80_h%3D300/fa5a7f61529d6e30a31c04edc63ccdec"}}]},"thisversionrun":"Mon Feb 22 2016 02:26:31 GMT+0000 (UTC)","thisversionstatus":"success","version":1}

任何帮助将不胜感激。 谢谢!

因为模型是一个包含记录的列表,所以脚本必须获取模型中的第一项。

像这样:

set wallpaperJson to {thisversionrun:"Mon Feb 22 2016 02:26:31 GMT+0000 (UTC)", |count|:1, results:{model:{{image:{alt:"April by Rich Cutrone on 500px", src:"https://drscdn.500px.org/photo/141047085/q%3D80_h%3D300/fa5a7f61529d6e30a31c04edc63ccdec"}}}}, newdata:true, thisversionstatus:"success", |version|:1, lastrunstatus:"success", |name|:"500HDPic"}

set wallpaperUrl to src of image of item 1 of (model of results of wallpaperJson)