hi,
I am using rest to query a json file and it works great! so far…
there’s just one thing:
here’s the json file:
[{"timestamp":1371722400,"tide":[{"timestamp":1371694797,"shift":3,"state":"Marea Alta"},{"timestamp":1371716769,"shift":0.6,"state":"Marea Baja"},{"timestamp":1371739775,"shift":3,"state":"Marea Alta"},{"timestamp":1371761712,"shift":0.5,"state":"Marea Baja"}],"unit":"m","sunriseTwilight":1371707173,"sunrise":1371709345,"sunsetTwilight":1371767326,"sunset":1371765154,"images":{"full":"http:\/\/charts.metcentral.com\/tide\/9d87ea0c7e0de1ea702033acbe40403c.png"}}]
there’s a nested timestamp field within tide, and a root timestamp.
here’s the ee template code I use:
{exp:rest url="http://magicseaweed.com/api/xxxxxxx/tide/?spot_id={segment_3}" offset="0" limit="1" record_type="m" verb="get" format="json" parse="inward"} <li>timestamp: {timestamp} {exp:nice_time date="{timestamp}" relative="no" format="%H:%i"}</li> <li> tide: <ul> {tide} <li>timestamp: {timestamp}</li> <li>time: {exp:nice_time date="{timestamp}" relative="no" format="%H:%i"}</li> <li>shift: {shift}{unit}</li> <li>state: {state}</li> <li>---</li> {/tide} </ul> </li> <li>unit {unit}</li> <li>sunriseTwilight: {sunriseTwilight} {exp:nice_time date="{sunriseTwilight}" relative="no" format="%H:%i"}</li> <li>sunrise: {sunrise} {exp:nice_time date="{sunrise}" relative="no" format="%H:%i"}</li> <li>sunsetTwilight: {sunsetTwilight} {exp:nice_time date="{sunsetTwilight}" relative="no" format="%H:%i"}</li> <li>sunset: {sunset} {exp:nice_time date="{sunset}" relative="no" format="%H:%i"}</li> <li> images {images} <ul> <li><img src="{full}" /></li> </ul> {/images} </li> {/exp:rest}
the nested timestamp variable will always render as the root timestamp variable.
now it’s a bit hard to ask the guys to change the api to a better naming, so I kindly ask you on what to do so that it works?!
here’s the rendered template: ———————————————-
timestamp: 1371722400 12:00
tide:
timestamp: 1371722400
time: 12:00
shift: 3m
state: High
—-
timestamp: 1371722400
time: 12:00
shift: 0.6m
state: Low
—-
timestamp: 1371722400
time: 12:00
shift: 3m
state: High
—-
timestamp: 1371722400
time: 12:00
shift: 0.5m
state: Low
—-
unit m
sunriseTwilight: 1371707173 07:46
sunrise: 1371709345 08:22
sunsetTwilight: 1371767326 00:28
sunset: 1371765154 23:52
images ... ———————————————
the bold timestamp values should be all different, but they’re all the same as the root…
any help highly appreciated!!!
stefan
|