Thanks for answering, Nick.
Hmm… The widgets would be displaying different things, depending on what kind of widget it is. Some would need text, others could perhaps need integers or floats. I like your suggestion that the widget will decode to the type that it needs. As you mention I should probably try to decode the JSON to a Dict of generic Json.value or perhaps a string representation, and let the widget do any conversions if needed. I'll give it a shot! On Tuesday, December 6, 2016 at 9:42:48 PM UTC+1, Nick H wrote: > > What sorts of widgets are we talking about? > > If you know what sorts of widgets you are displaying, then you should also > know what types of data they need. If this is true, then you could decode > your JSON to simple "Dict String Json.Value". Then your widgets will have > more fine-grained decoders connected to them. You can pass them the values > for properties x, y, and z from the Dict, and the widgets will try to > decode further. > > On Tue, Dec 6, 2016 at 11:50 AM, Hans Rune Bergheim <[email protected] > <javascript:>> wrote: > >> Hi! >> >> >> I'd like to create a simple dashboard in Elm, that displays some graphs >> and numbers from json-data. The dashboard should be fully configurable, >> meaning that the users should have a config-file saying they would like to >> get data from service foo, and want to display widget a, b and c, using >> properties x,y, and z of the data. The names and contents of the properties >> may be any name and type, as the data source could be any webservice. >> >> >> >> I've been trying to wrap my head around how to do this in elm, but I'm >> coming up short. Is Elm a bad fit for this type of application, or am I >> just missing a clever way of doing it? I've seen multiple examples of >> dynamic JSON (like this: >> https://www.brianthicks.com/post/2016/10/03/decoding-json-with-dynamic-keys/) >> >> , but they all know what kind(s) of object(s) that's being decoded at >> compile time, which is not the case here. >> >> >> >> This is fairly straightforward to do in JavaScript, but I'm trying to get >> as much Elm-time as I can these days :-) >> >> >> PS: Coming from JS and .Net-land, I'm having a pretty hard time getting >> to know Elm, but a big shoutout to Richard Feldman and his Elm In >> Action-book! I am really enjoying each chapter so far :) Highly >> recommended! >> >> >> Hans >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Elm Discuss" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected] <javascript:>. >> For more options, visit https://groups.google.com/d/optout. >> > > -- You received this message because you are subscribed to the Google Groups "Elm Discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
