gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 07:37:36 29 4
gpt4 key购买 nike

你好,我正在尝试使用 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}

enter image description here

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

最佳答案

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

像这样:

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)

关于javascript - 使用 AppleScript 和 JSON 解析数据时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35545789/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com