- Platform information:
- Hardware: Intel i3
- OS: Debian
- openHAB version: 4.1.1
Hi community,
I`m fetching the currently played song with http binding from a webradio service.
I get a json response like this:
[{"stationId":"5.0.0","id":"29440449","artist":"Leony","title":"Holding on","starttime":1710680016,"duration":172,"type":"music","cover":"https://onair.swr.de/covers/swr/swrhfdb1.KONF.50541227?stationid=28471","hook":"https://hooksswr-a.akamaihd.net/28471/1831958.m.mp3","url":{},"playingMode":2},{"stationId":"5.0.0","id":"29440441","artist":"Kenya Grace","title":"Strangers","starttime":1710679846,"duration":172,"type":"music","cover":"https://onair.swr.de/covers/swr/swrhfdb1.KONF.51268978?stationid=28471","hook":"https://hooksswr-a.akamaihd.net/28471/1918595.m.mp3","url":{},"playingMode":0},{"stationId":"5.0.0","id":"29440409","artist":"Harry Styles","title":"Watermelon sugar","starttime":1710679592,"duration":173,"type":"music","cover":"https://onair.swr.de/covers/swr/swrhfdb1.KONF.46947077?stationid=28471","hook":"https://hooksswr-a.akamaihd.net/28471/M0582167.001.m.mp3","url":{},"playingMode":0},{"stationId":"5.0.0","id":"29440406","artist":"CIVO / Maxe","title":"Keine Homies","starttime":1710679459,"duration":136,"type":"music","cover":"https://onair.swr.de/covers/swr/swrhfdb1.KONF.52158311?stationid=28471","hook":"https://hooksswr-a.akamaihd.net/28471/1989392.m.mp3","url":{},"playingMode":0},{"stationId":"5.0.0","id":"29440387","artist":"Meduza x James Carter feat. Elley Duhe & FAST BOY","title":"Bad memories","starttime":1710679295,"duration":147,"type":"music","cover":"https://onair.swr.de/covers/swr/swrhfdb1.KONF.49432357?stationid=28471","hook":"https://hooksswr-a.akamaihd.net/28471/M0687048.001.m.mp3","url":{},"playingMode":0},{"stationId":"5.0.0","id":"29440361","artist":"Coolio","title":"Gangsta's paradise","starttime":1710678967,"duration":240,"type":"music","cover":"https://onair.swr.de/covers/swr/swrhfdb1.KONF.46115928?stationid=28471","hook":"https://hooksswr-a.akamaihd.net/28471/M0519603.001.m.mp3","url":{},"playingMode":0},{"stationId":"5.0.0","id":"29440346","artist":"southstar","title":"Miss you","starttime":1710678795,"duration":200,"type":"music","cover":"https://onair.swr.de/covers/swr/swrhfdb1.KONF.49523007?stationid=28471","hook":"https://hooksswr-a.akamaihd.net/28471/1707782.m.mp3","url":{},"playingMode":0},{"stationId":"5.0.0","id":"29440328","artist":"Tate McRae","title":"Greedy","starttime":1710678660,"duration":130,"type":"music","cover":"https://onair.swr.de/covers/swr/swrhfdb1.KONF.51276203?stationid=28471","hook":"https://hooksswr-a.akamaihd.net/28471/1922743.m.mp3","url":{},"playingMode":0},{"stationId":"5.0.0","id":"29440300","artist":"RAYE feat. 070 Shake","title":"Escapism","starttime":1710678394,"duration":205,"type":"music","cover":"https://onair.swr.de/covers/swr/swrhfdb1.KONF.50648987?stationid=28471","hook":"https://hooksswr-a.akamaihd.net/28471/1903142.m.mp3","url":{},"playingMode":0},{"stationId":"5.0.0","id":"29440272","artist":"Ayliva","title":"Lieb mich","starttime":1710678216,"duration":177,"type":"music","cover":"https://onair.swr.de/covers/swr/swrhfdb1.KONF.52391402?stationid=28471","hook":"https://hooksswr-a.akamaihd.net/28471/2001467.m.mp3","url":{},"playingMode":0},{"stationId":"5.0.0","id":"29440271","artist":"Avicii feat. Sandro Cavazza","title":"Without you","starttime":1710677994,"duration":179,"type":"music","cover":"https://onair.swr.de/covers/swr/swrhfdb1.KONF.45718620?stationid=28471","hook":"https://hooksswr-a.akamaihd.net/28471/M0489572.001.m.mp3","url":{},"playingMode":0}]
I like to get the current song, which should be easy with JSONPATH.
I tried it as JSONPATH Profile ($[0]) and as Status Transformation (JSONPATH:$[0]) but the result is the same:
{stationId=5.0.0, id=29440498, artist=Armani White, title=Billie Eilish., starttime=1710680187, duration=98, type=music, cover=https://onair.swr.de/covers/swr/swrhfdb1.KONF.49560942?stationid=28471, hook=https://hooksswr-a.akamaihd.net/28471/1721871.m.mp3, url={}, playingMode=2}
As you can see the quotation marks are removed, but I like to keep them as I want to postprocess the json data. (Widget / SQL / etc.) I can only find the other way round where people try to remove the quotation marks, which would be easy with a concated regex…
Online evaluator keeps them: https://jsonpath.com/
How can I achieve this result?
Thank you
Edit:
Got it working in a rule, but would be nicer without rule…