Skip to content

Concept: JSON Decoders #538

@jiegillet

Description

@jiegillet

Design

Goal

The Goal is to learn to use the Json.Decode and Json.Encode modules.

Learning objectives

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...)
  • decode data structures (list, dict, nullable)
  • decode objects (field, at)
  • deal with uncertainty (maybe, oneOf)
  • modify and chain decoders (map, andThen, succeed)
  • test a decoder on a string input (decodeString)

Out of scope

  • encoder aliases (array, set)
  • more niche decoders (array, keyValuePairs, oneOrMore, index, null, value)
  • dealing with Error and fail
  • decoding recursive structures (lazy, a quick mention is fine)

Concepts

The concept this exercise unlocks is:

  • json

Prerequisites

  • strings
  • lists
  • dict
  • records
  • maybe
  • custom-types (?)

Analyzer

TBD depending on the exercise


Comments

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions