ByteString parser for a simple, monomorphic JSON datatype.
- data JSON
- decode :: ByteString -> Either (ParseError, ByteString) JSON
- break :: ByteString -> (Either ParseError JSON, ByteString)
- data Style = Compact
- encode :: Style -> JSON -> ByteString
- data Schema counter
- schema :: Counter counter => JSON -> Schema counter
- schemas :: Counter counter => [JSON] -> [(counter, Schema counter)]
- data OneMany
- class Display t where
- class Escape t where
- escape :: t -> t
- escaped :: Char -> Bool
ByteString as any JSON literal.
Split out the first parseable JSON literal from the input, returning the result of the attempt along with the remainder of the input or the whole input if not parseable item was discovered.
Style of serialization. Compact is the only one that is implemented at present.
The type of JSON schemas. We treat the atomic types simply whereas objects and arrays are treated specially.
Objects are treated as maps of keys to sets of schema types. Say a certain type of object sometimes has a string at a certain key and sometimes has a null at that key; we should merge them and say the schema of that key is a union of string and null.
Arrays admit measure in the sense of how many elements there are of a certain kind. We support three measures at present: any, one or more and individual counts. We expect the any measure to prevail practice. Arrays are also ordered; so one can distinguish an array that interleaves strings and ints from one that is all strings and then all ints.
Develop a schema for a list of JSON data, collating schemas according to the measure, a well-ordered semigroup.
Class of JSON escapable text. The solidus (
/) is always escaped, as are
all ASCII control characters. Non-ASCII control characters