Decoding Json that contain Json using Elm

Lucamug
1 min readJun 15, 2017

--

Live demo: https://lucamug.github.io/elm-meta-json-decoder/

I created a simple page to test APIs that output Json that contain Json.

To extract recursively Json in one step I used Json.Decode.Extra.doubleEncoded.

The Json file is store in the cloud at http://www.jsoneditoronline.org/?id=3e4dbce6f34017948c0a5ea43bcaf141.

Jsoneditoronline returns the Json file wrapped in some metadata and the original data is added as a string into the “data” key.

For example, if this is the original data:

{
"things": [
{
"id": "01",
"name": "Nature"
},
{
"id": "02",
"name": "Sport"
}
]
}

Jsoneditoronline would return

{
"_id": "3e4dbce6f34017948c0a5ea43bcaf141",
"_rev": "6-634526ead8f1995af2e81ecfb4d9c678",
"name": "metaThings",
"data": "{\n \"things\": [\n {\n \"id\": \"01\",\n \"name\": \"Nature\"\n },\n {\n \"id\": \"02\",\n \"name\": \"Sport\"\n }\n ]\n}\n",
"updated": "2017-06-15T08:27:42.221Z"
}

You can find the code of this project at https://github.com/lucamug/elm-meta-json-decoder

--

--

No responses yet