1

I am using the weatherunderground api, and I would like to access the forecast only for today. I usually use parsed_json[][] until I get the variable I need, but in this case there is an array. Here is my code:

function findWeather() {



  jQuery(document).ready(function($) {
  $.ajax({
  url : "http://api.wunderground.com/api/c531e176f43b999d/forecast/q/CT/Old_Greenwich.json",
  dataType : "jsonp",
  success : function(parsed_json) {

  var forecasts = parsed_json['forecast']['txt_forecast']['forecastday: 0']['fcttext'];

   var forecastString = "The weather is" + forecasts + "."
   speak(" test" + forecastString);
  }
  });
});  
}
function speak(x) {
var msg = new SpeechSynthesisUtterance(x);
    window.speechSynthesis.speak(msg);
}

If you go to the URL, you will see the entire sheet and the info I am trying to access. I've been trying to solve this for a few hours, and can't find any help with google.

1 Answer 1

2

Try this:

parsed_json['forecast']['txt_forecast']['forecastday'][0]['fcttext'];

Don't know what you expect the :0 to do, but it won't de-reference the array.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.