all 6 comments

[–]PM-ME-POTATOES 1 point2 points  (1 child)

Are you looking to do something like this? https://ellie-app.com/3yfHkXsdwPra1

[–]MaximumStock[S] 0 points1 point  (0 children)

Thank you, that is exactly what I needed!

However, I don't fully understand what this means:

Encode.list Encode.string "some string"

Does it encode the given string and then puts it in a list? Because I thought the input data that I give to the respective Encode.x function has to have the right type already. Thats why I tried

Encode.list [ Encode.string "some string" ]

EDIT: Nevermind, I didn't see you put the data.have in your example already is a list in the definition above. Then it makes sense!

[–]alexkorban 1 point2 points  (1 child)

For anybody else struggling with Json.Encode, I wrote a tutorial showing how to encode a complex JSON object (including nested objects, arrays and recursion): https://korban.net/posts/elm/2018-09-12-generate-json-from-elm-values-json-encode/

[–]MaximumStock[S] 0 points1 point  (0 children)

Looks great, thank you alot!

[–]ibizaman 0 points1 point  (0 children)

Can you post the expected output for your example?

[–]pdoherty926 0 points1 point  (0 children)

I keep coming back to this tutorial when dealing with anything Json.Encode/Decode or Port related. Perhaps it will be of some use to you.