Elm decoding unknown json structure : <p>I've just started working with Elm to do some front-end prototyping using a Rest API I'm working on. In general, the API returns "reasonable" data structures that can be decoded because the keys and value-types are well-known, but several resource types return a <code>data</code> entry that just has raw json that has no predetermined structure.</p>

<p>Everything I've read so far seems to assume you know the structure of the data you're decoding, whereas in plain js it's relatively easy to loop over the keys and reflect on the types in order to determine how they should be handled at runtime. I'm not seeing a clear path toward handling this kind of data in Elm yet.</p>

<p>E.g.,</p>

<pre><code>{
  "name":"foo",
  "data": {
    "bar": [{"baz":123}, "quux"]
  },
  ...
}
</code></pre>

<p>I'd like to know if it is currently possible to parse the value of the <code>data</code> entry with something akin to</p>

<pre><code>function go(obj)
    for key in keys(foo)
        if foo[key] is an object
            go(foo[k])
        else if foo[key] is an array
            map(go, foo[k])
        ...
</code></pre>

<p>Specifically:</p>

<ol>
<li>Is it currently possible to handle unknown, possibly deeply nested and heterogeneous json data in Elm?</li>
<li>If so, can you give me the key concept or high level intuition on how the author(s) intended data like this to be decoded?</li>
</ol>
