A Module for MagicMirror designed to display parts or the whole JSON response from an api.
# Clone the repository into MagicMirror/modules directory and install the dependencies
cd ./modules
git clone https://github.com/DanielHabenicht/MMM-json.git
npm install
- Create an entry in 'config/config.js' with your url and any config options.
Basic Example:
{
module: 'MMM-json',
position: 'bottom_left',
config: {
url: "https://jsonplaceholder.typicode.com/users", // Path to your json api
}
},
Advanced Example:
{
module: "MMM-json",
position: "bottom_left",
header: "JSON",
config: {
url: "https://jsonplaceholder.typicode.com/users",
headerIcon: "fa-cube",
values: [
{
title: "Name",
query: "$[1].name"
},
{
title: "Coordinate 1",
query: "$[?(@.id==2)].address.geo.lat",
prefix: "LAT",
suffix: "°"
},
{
title: "Coordinate 2",
query: "$[?(@.name=='Ervin Howell')].address.geo.lat",
prefix: "LON",
suffix: "°"
}
]
}
},
Property | Description |
---|---|
url |
The url where to get the json response from.
Type: string
Default: https://jsonplaceholder.typicode.com/users
|
refreshInterval |
The interval with which the url is queried and your values are updated.
Type: int (seconds)
Default: 300000 => 5 minutes
|
header |
Deprecated, use the built in header
in the config
|
headerIcon |
The Icon for your Header
Type: string any FontAwesome Icon
Default: (none)
|
values |
Custom Configuration of the values you want to display (see below)
Type: array
Default: [] Which means it displays all first level attributes (or the first element of an array).
|
Value-Property | Description |
---|---|
title |
The Title of the Property displayed on the screen
Type: string
Default: The attribute name |
query |
The jsonpath to the value of your json response you want to display. Here you can test your expression
Type: string
Example: $[?(@.name=='Ervin Howell')].address.geo.lat
|
suffix |
String that will be displayed behind your query value
Type: string
Example: %
|
prefix |
String that will be displayed in front of your query value
Type: string
Example: EUR
|
Attribution of some basic work and inspiration goes to https://github.com/tkrywit/MMM-Solar.