You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{
module: 'MMM-json',
position: 'top_right',
header: "Cat-Location",
config: { //
url: http://192.168.0.12:8080/pets/position, // Path to your json api
refreshInterval: 60000,
jq: '. | map(if .where == 2 then .where = "outside" elif . == 1 then .where = "inside" else . end)',
values: [
{
title: "Leia",
query: ["$[0].where", "$[0].since"],
prefix: ["", "(since"],
suffix: ["",")"]
},
{
title: "Luke",
query: ["$[1].where", "$[1].since"],
prefix: ["", "(since"],
suffix: ["",")"]
}
],
styleRules: [ // Provide custom style rules for any value
{
match: (value) => value == "2",
style: "color: orange; font-weight: bold;"
},
{
match: (value) => value == "1",
style: "color: lawngreen; font-weight: bold;"
}
],
headerIcon: "fa-cat"
}
},
When I test the jq code on https://jqplay.org/ for example, it correctly replaces "2" with the string "outside" and "1" with inside. But still, on my mirror, the values 2 and 1 are displayed - it seems the jq transformation is not applied? Can you help me out here?
Many thanks! :)
The text was updated successfully, but these errors were encountered:
Hey,
this probably has to do with the package used to process jq commands in this module.
It does not use the standard jq syntax but jq-node (which is more powerful and sometimes different in syntax).
It seems like your jq syntax does not work with this package:
Thanks for your answer on this! Unfortunately, I did not find out anything anywhere about that jq-node syntax... Also, are you sure, when using Multi Values as in my example above, the jq is applied at all? I've been trying very simple transformations and the JSON string never got transformed...
Nevertheless, thanks anyway. I might spin up a docker which processes the JSON with regular JQ and then passes it on to your module.
Yeah it definitely works, but I've als run into issues with jq.node because it lacks documentation.
However I did choose it purposly because it works cross platform and there is no need to install jq as an extra package. Most of the other jq packages just wrap jq on commandline.
I will try to add more documentation to the jq.node package.
Hi Daniel
I have the impression, my jq.node transformation is not working and I cant figure out why:
This is my JSON, that I want to transform:
And this is my config for the module:
When I test the jq code on https://jqplay.org/ for example, it correctly replaces "2" with the string "outside" and "1" with inside. But still, on my mirror, the values 2 and 1 are displayed - it seems the jq transformation is not applied? Can you help me out here?
Many thanks! :)
The text was updated successfully, but these errors were encountered: