Algebraic data types and pattern matching for JSON