You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Game Maker Studio Mac运行时执行HTTP API请求时崩溃

Game Maker Studio Mac运行时JSON解析崩溃问题

在Game Maker Studio中,将JSON API返回值存储到本地变量时,Mac运行时出现崩溃。以下是具体代码及问题细节:

Create事件代码

request_handle = -1;

windspeed = 0;
winddirection = 0;

url = "https://api.open-meteo.com/v1/forecast?latitude=51.5085&longitude=-0.1257&current=wind_speed_10m,wind_direction_10m&wind_speed_unit=ms&timeformat=unixtime&timezone=Europe%2FLondon&past_minutely_15=1&forecast_minutely_15=4";
apiinfo = json_decode(http_get(url));

Async HTTP事件代码

show_debug_message("Running Async");
windspeed = apiinfo.current.wind_speed_10m;
show_debug_message(windspeed);

HTTP请求返回的JSON结果

{
  "latitude": 51.5,
  "longitude": -0.120000124,
  "generationtime_ms": 0.0479221343994141,
  "utc_offset_seconds": 3600,
  "timezone": "Europe/London",
  "timezone_abbreviation": "BST",
  "elevation": 23,
  "current_units": {
    "time": "unixtime",
    "interval": "seconds",
    "wind_speed_10m": "m/s",
    "wind_direction_10m": "°"
  },
  "current": {
    "time": 1713428100,
    "interval": 900,
    "wind_speed_10m": 2.31,
    "wind_direction_10m": 355
  }
}

预期windspeed变量可获取JSON结果中的wind_speed_10m值,但仅触发Mac运行时崩溃。尝试使用ds_map_find_value定位该值也未成功,相关代码如下:

var response = (ds_map_find_value(async_load, "current"));
var person = json_decode(response);
show_debug_message(person);

内容的提问来源于stack exchange,提问作者Alejandro Corredor Parra

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.25 19:02:40