Tide data issues

  • 1
  • Question
  • Updated 6 years ago
var high_tide = parsed_json['tide']['tideSummary'][0]['data.type'];

Anybody see why I'm getting undefined when I try to extract the tide type using the code above? I've been trying to figure it out for days so any help would be greatly appreciated!

Thanks!
Photo of mtuman1843

mtuman1843

  • 8 Posts
  • 0 Reply Likes

Posted 6 years ago

  • 1
Photo of afelicioni

afelicioni

  • 227 Posts
  • 43 Reply Likes
What do you expect to get? Value, property, sort of? The code above is outside logic.
Photo of afelicioni

afelicioni

  • 227 Posts
  • 43 Reply Likes
EDIT: can the above data.type just get replaced with maxheight?
Photo of afelicioni

afelicioni

  • 227 Posts
  • 43 Reply Likes
Double forgive me, but I don't know if I messed with the forum or I am in mess myself.


var high_tide = parsed_json['tide']['tideSummary'][0]['data']['type'];
Photo of mtuman1843

mtuman1843

  • 8 Posts
  • 0 Reply Likes
That's it! Thanks so much!
Photo of mtuman1843

mtuman1843

  • 8 Posts
  • 0 Reply Likes
One last question...I'm attempting to match the type of tide (high or low) with the corresponding time of day.

I'm using the following code but I'm not sure if I'm on the right track because the time/type matches don't seem right.

var high_tide = parsed_json['tide']['tideSummary'][0]['date']['pretty'];var type = parsed_json['tide']['tideSummary'][0]['data']['type'];
Photo of afelicioni

afelicioni

  • 227 Posts
  • 43 Reply Likes
the tideSummary struct has a lot of children, so the 0 grabs just the first.

AFAIK, the children are a sort of collection of events, including Low Tide and High Tide but also rising and setting events for moon and sun.
Maybe you nedd to code a cycle around tideSummary to get dates of next low and high tide events.