The Goal is to learn to use the Json.Decode
and Json.Encode
modules.
Students should be able to
- encode any JSON
Value
(Json.Encode.object
,list
and other primitives) - prettify a value (
encode
) - understand why decoders are useful even though the concept is unusual
- decode JSON primitives (
bool
,int
,string
,null
...) - decode data structures (
list
,dict
,nullable
) - decode objects (
field
) - deal with uncertainty (
maybe
,oneOf
) - modify and chain decoders (
map
,andThen
,succeed
,fail
) - run a decoder on a string input (
decodeString
)
- encoder aliases (
array
,set
) - more niche decoders (
array
,keyValuePairs
,oneOrMore
,index
,at
,value
) - dealing with
Error
specifics - decoding recursive structures (
lazy
, a quick mention is fine)
The concept this exercise unlocks is:
json
- strings
- lists
- tuples
- dict
- records
- maybe
- custom-types
- pattern matching
Make sure that
decodeUser
usesdecodeId
anddecodeName
decodeComment
usesdecodeId
,decodePullRequestReviewId
,decodeUser
,decodeSide
,decodeLinks
decodeComments
usesdecodeComment