-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | High-performance JSON parser and encoder
--
-- This library parses JSON into a Value type that is consistent
-- with the ABNF described in RFC 7159. The parser is about six
-- times faster than the parser that aeson provides. This parser
-- is however, non-resumable, so if resumable parsing is important,
-- aeson should be preferred.
--
-- This library does not include any functions or typeclasses to help
-- users marshal Value to their application-specific data types.
-- Such functions and typeclasses are outside the scope of this library.
-- If anyone writes a library that offers users these conveniences open a
-- issue so that the json-syntax documentation can point users
-- to it.
@package json-syntax
@version 0.2.3.0
module Json
-- | The JSON syntax tree described by the ABNF in RFC 7159. Notable design
-- decisions include:
--
--
-- - True and False are their own data constructors
-- rather than being lumped together under a data constructor for boolean
-- values. This improves performance when decoding the syntax tree to a
-- Bool.
-- - Object uses an association list rather than a hash map.
-- This is the data type that key-value pairs can be parsed into most
-- cheaply.
-- - Object and Array both use Chunks rather
-- than using SmallArray or cons-list directly. This a middle
-- ground between those two types. We get the efficent use of cache lines
-- that SmallArray offers, and we get the worst-case
-- O(1) appends that cons-list offers. Users will typically fold
-- over the elements with the Foldable instance of
-- Chunks, although there are functions in Data.Chunks
-- that efficently perform other operations.
--
data Value
Object :: !SmallArray Member -> Value
Array :: !SmallArray Value -> Value
String :: {-# UNPACK #-} !ShortText -> Value
Number :: {-# UNPACK #-} !Scientific -> Value
Null :: Value
True :: Value
False :: Value
-- | A key-value pair in a JSON object. The name of this type is taken from
-- section 4 of RFC 7159.
data Member
Member :: {-# UNPACK #-} !ShortText -> !Value -> Member
[key] :: Member -> {-# UNPACK #-} !ShortText
[value] :: Member -> !Value
-- | Exceptions that can happen while parsing JSON. Do not pattern match on
-- values of this type. New data constructors may be added at any time
-- without a major version bump.
data SyntaxException
EmptyInput :: SyntaxException
ExpectedColon :: SyntaxException
ExpectedCommaOrRightBracket :: SyntaxException
ExpectedFalse :: SyntaxException
ExpectedNull :: SyntaxException
ExpectedQuote :: SyntaxException
ExpectedQuoteOrRightBrace :: SyntaxException
ExpectedTrue :: SyntaxException
IncompleteArray :: SyntaxException
IncompleteEscapeSequence :: SyntaxException
IncompleteObject :: SyntaxException
IncompleteString :: SyntaxException
InvalidEscapeSequence :: SyntaxException
InvalidLeader :: SyntaxException
InvalidNumber :: SyntaxException
LeadingZero :: SyntaxException
UnexpectedLeftovers :: SyntaxException
-- | Decode a JSON syntax tree from a byte sequence.
decode :: Bytes -> Either SyntaxException Value
-- | Encode a JSON syntax tree.
encode :: Value -> Builder
-- | Infix pattern synonym for Member.
pattern (:->) :: ShortText -> Value -> Member
-- | An array with no elements (i.e. [])
emptyArray :: Value
-- | An object with no members (i.e. {})
emptyObject :: Value
-- | Construct a JSON object with one member.
object1 :: Member -> Value
-- | Construct a JSON object with two members.
object2 :: Member -> Member -> Value
-- | Construct a JSON object with three members.
object3 :: Member -> Member -> Member -> Value
-- | Construct a JSON object with four members.
object4 :: Member -> Member -> Member -> Member -> Value
-- | Construct a JSON object with five members.
object5 :: Member -> Member -> Member -> Member -> Member -> Value
-- | Construct a JSON object with six members.
object6 :: Member -> Member -> Member -> Member -> Member -> Member -> Value
-- | Construct a JSON object with seven members.
object7 :: Member -> Member -> Member -> Member -> Member -> Member -> Member -> Value
-- | Construct a JSON object with nine members.
object8 :: Member -> Member -> Member -> Member -> Member -> Member -> Member -> Member -> Value
-- | Construct a JSON object with nine members.
object9 :: Member -> Member -> Member -> Member -> Member -> Member -> Member -> Member -> Member -> Value
-- | Construct a JSON object with ten members.
object10 :: Member -> Member -> Member -> Member -> Member -> Member -> Member -> Member -> Member -> Member -> Value
-- | Construct a JSON object with eleven members.
object11 :: Member -> Member -> Member -> Member -> Member -> Member -> Member -> Member -> Member -> Member -> Member -> Value
-- | Construct a JSON object with twelve members.
object12 :: Member -> Member -> Member -> Member -> Member -> Member -> Member -> Member -> Member -> Member -> Member -> Member -> Value
instance GHC.Exception.Type.Exception Json.SyntaxException
instance GHC.Show.Show Json.SyntaxException
instance GHC.Classes.Eq Json.SyntaxException
instance GHC.Show.Show Json.Value
instance GHC.Classes.Eq Json.Value
instance GHC.Show.Show Json.Member
instance GHC.Classes.Eq Json.Member
-- | Flatten nested JSON objects into a single JSON object in which the
-- keys have been joined by the separator.
module Json.Flatten
-- | Flatten a json value, recursively descending into objects and joining
-- keys with the separator. For example:
--
--
-- { "name": "bilbo"
-- , "occupation":
-- { "name": "burglar"
-- , "start": "2022-05-30"
-- }
-- , "height": 124
-- , "favorites": ["adventures","lunch"]
-- }
--
--
-- Becomes:
--
--
-- { "name": "bilbo"
-- , "occupation.name": "burglar"
-- , "occupation.start": "2022-05-30"
-- , "height": 124
-- , "favorites": ["adventures","lunch"]
-- }
--
--
-- Currently, the implementation of this function throws an exception if
-- any separator other than period is used. This may be corrected in a
-- future release.
flatten :: Char -> Value -> Value
module Json.Smile
-- | Encode a Json Value to the Smile binary format. This encoder
-- does not produce backreferences.
encode :: Value -> Builder
-- | Encode a number using as SMILE BigInteger token type (prefix
-- 0x26).
encodeBigInteger :: Integer -> Builder
-- | Encode a string.
encodeString :: ShortText -> Builder
-- | Encode a string in which all characters are ASCII. This precondition
-- is not checked. Resulting output will be corrupt if this condition is
-- not satisfied.
encodeAsciiString :: ShortText -> Builder
-- | Encode a key.
encodeKey :: ShortText -> Builder
-- | Encode a key in which all characters are ASCII. This precondition is
-- not checked. Resulting output will be corrupt if this condition is not
-- satisfied.
encodeAsciiKey :: ShortText -> Builder