Api parsing error

Json array has a parsing error.

main.js

function Btn1_click() {
    json = loadJSONObject("json/openweatherapi.json")
    JSONArray weatherData = json.getJSONArray("api");
    openweatherapi = new openweatherapi[weatherData.size()];
    for (int i = 0; i < openweatherapi.size(); i++) {
        JSONObject weatherapi = weatherData.getJSONObject(i);
    }
    JSONObject weather = weatherapi.getJSONObject("current");
    Float x = weather.getFloat("sunrise");
    Float y = weather.getFloat("sunset");
    Textbox1.text = x.tostring()
    Textbox2.text = y.tostring()
}

openweatherapi.json

api:{
   "lat": 40.79,
   "lon": -81.347,
   "timezone": "America/New_York",
   "timezone_offset": -14400,
   "current": {
      "dt": 1647561849,
      "sunrise": 1647516826,
      "sunset": 1647560024,
      "temp": 289.69,
      "feels_like": 288.68,
      "pressure": 1014,
      "humidity": 49,
      "dew_point": 278.95,
      "uvi": 0,
      "clouds": 40,
      "visibility": 10000,
      "wind_speed": 0,
      "wind_deg": 0,
      "weather": [
         {
            "id": 802,
            "main": "Clouds",
            "description": "scattered clouds",
            "icon": "03n"
         }
      ]
   };

This look like java code to me, not javascript.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.