• Resolved 00wabbit

    (@00wabbit)


    https://api.synopticdata.com/v2/stations/latest?STID=CACWP&vars=air_temp&UNITS=ENGLISH&token=b6b8503025bb44d196083c5404bdea76

    I am having trouble understanding what the syntax is to read deeper into the json data.
    This is the api for a weather station. I want to be able to get the name, station ID, air_temp, Precip, wind direction, and some other stuff.

    For now I limited the api to the air temp just to make it simpler for me to read. I feel confident that if I can get air temp to work, then I can figure out the others.

    I was able to get the Station name and ID to print with this:

    {subloop-array:STATION:-1}
    {subloop:station.name:-1}
    {STATION.NAME} {STATION.STID}
    {/subloop:STATION.name}
    {/subloop-array:STATION}

    I am having trouble getting air temp which is nested under OBSERVATIONS.

    What I want to get on the screen is the air_temp_value_1 value.
    I’ve tried tweaking this so many times, that I am just lost now.

    {subloop-array:STATION:-1} {STATION.OBSERVATIONS} Current Temperature: {subloop:STATION.air_temp_value_1:-1}{value}
    {/subloop:STATION.air_temp_value_1:-1}
    {/subloop-array:STATION:-1}

    Can you point me in the right direction?

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author berkux

    (@berkux)

    Hi,

    try this:

    [jsoncontentimporter url=https://api.synopticdata.com/v2/stations/latest?STID=CACWP&vars=air_temp&UNITS=ENGLISH&token=b6b8503025bb44d196083c5404bdea76]
    {subloop-array:STATION:-1}
    ELEVATION: {STATION.ELEVATION}, NAME: {STATION.NAME}, STID: {STATION.STID}
    <br>Current Temperature: 
    {subloop:STATION.OBSERVATIONS:-1}
    {subloop:STATION.OBSERVATIONS.air_temp_value_1:-1}
    {STATION.OBSERVATIONS.air_temp_value_1.value}
    {/subloop:STATION.OBSERVATIONS.air_temp_value_1}
    {/subloop:STATION.OBSERVATIONS}
    {/subloop-array:STATION}
    [/jsoncontentimporter]

    Bernhard

    • This reply was modified 4 years ago by berkux.
    • This reply was modified 4 years ago by berkux.
    Thread Starter 00wabbit

    (@00wabbit)

    That works except for the <br> doesn’t seem to break for me.

    Is there a way to get the air temp to display as a whole number? Right now it’s 30.76, can I make it display as 31?

    Thanks for your help.

    Plugin Author berkux

    (@berkux)

    <<Is there a way to get the air temp to display as a whole number? Right now it’s 30.76, can I make it display as 31?>>
    Rounding is a feature of the PRO plugin. You might change the JSON?

    • This reply was modified 4 years ago by berkux.
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘I’m not a coder need help with syntax, almost got it I think’ is closed to new replies.