Parse JSON response in google sheets

I have very limited computer programing experience and have never done anything in JavaScript before so please be patient with me.

I’m trying to create a simple display in google sheets of my tempest data. Thanks to google/youtube, I found general code online that is able to import the entire JSON file and run a trigger that updates the data every minute. However, I noticed that not all the fields/variables come in each time the trigger runs and this is throwing off my reference cells. After consulting with weatherflow, they said that I need to look for the presence of the fields I’m interested in by name rather than the order they arrive. How do I go about doing that?

Based on my limited experience, my assumption is that I need to do this in this function:

So, if someone could help me with an example of parsing out Obs_Precip_Accum_Local_Day and Obs_Precip_Minutes_Local_Day from the main file as an example then I think I could probably figure out the rest.

Thanks in advance

@adcarmic, can you show where you are grabbing the data now by position?
–Sam

I assume you are asking me where I’m pulling the data from. It’s from the api: https://swd.weatherflow.com/swd/rest/observations/station/22007?api_key=20c70eae-e62f-4d3b-b3a4-8586e90f3ac8

No. The code that pulls the individuals fields out of the JSON. That’s what I need to see.

–Sam

I’m using code I found online and I don’t know where that process is taking place. But here’s a link to that code: https://github.com/bradjasper/ImportJSON/blob/master/ImportJSON.gs.

And I’m using this function above it:

function importJSONupdate() {
var d = new Date();
var timeStamp = d.toLocaleTimeString();
var cellValue = ‘=Transpose(ImportJSONBasicAuth("https://swd.weatherflow.com/swd/rest/observations/station/22007?api_key=20c70eae-e62f-4d3b-b3a4-8586e90f3ac8","’ + timeStamp + ‘"))’;
SpreadsheetApp.getActiveSheet().getRange(‘A2’).setValue(cellValue);
}

Sorry I can’t be of more help and narrow it down for you.

That should be enough.
I’ll see what I can come up with for you.
–Sam

I thought there was a WeatherFlow written function that saved data to a Google Sheet.

1 Like
1 Like

I’m using IFTTT for most of the variables in my display but there are a few that I want to use that aren’t available through the site. At least to my knowledge. I couldn’t get things like lightning strike distance