state-machine-systems / JsonCodec

JSON combinator library for BuckleScript/Reason
Apache License 2.0
38 stars 7 forks source link

Arrays as tuples #2

Open johnwright opened 7 years ago

johnwright commented 7 years ago

It's common in JSON to use arrays as tuples, e.g.

{
  "pairs": [
    [1, 2],
    [3, 4]
  ]
}

To support this pattern, add pair, triple, quad codecs (and/or tuple2, tuple3, tuple4 etc.)

When decoding arrays as tuples, unexpected extra elements should be ignored.