@lkthomas said in From JSON to display on MM:
which module should I use as an example for JSON iteration?
How could I filter the closest timestamp with current time then display it in minute on MM?
there is an array filter function
you pass in the array, the logic looks at each element one by one… true means keep it in the results, false say don’t keep it.
the resulting array is the good subset of the total
javascript and json are very close friends.
url get request can return a javascript object of the json text …
then u can pass the array part (data I think from your sample) to the filter…
if you use fetch , you can do this in the browser side of the module,
otherwise have to use a helper…
https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch
fetch('http://example.com/movies.json')
.then((response) => response.json())
.then((data) => console.log(data));
data is now a js object of the json text
see my sample module for building a starter…
https://github.com/sdetweil/SampleModule
the browserside of the module (I call it modulename.js, cause its name MUST match the name of the module, and it has to be in a folder called the exact same) creates a small segment of html content
(either text or actual DOM nodes) … and gives that to MM when requested (the getDom() function) and MM will put the content where u configured the module to have its content shown.
so folder, modulename.js and modulename all match
if you do the fetch on a timed cycle, once u have the data, call updateDom() to inform mm your module has new content, then mm will call your getDom() to get the new content.
getDom() either creates the content or knows where the previously created content is.