-- 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.7.2
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
PossibleOverflow :: SyntaxException
-- | Typeclass for types that can be encoded as JSON.
class ToValue a
toValue :: ToValue a => a -> Value
-- | Decode a JSON syntax tree from a byte sequence.
decode :: Bytes -> Either SyntaxException Value
-- | Decode newline-delimited JSON. Both the LF and the CRLF conventions
-- are supported. The newline character (or character sequence) following
-- the final object may be omitted. This also allows blanks lines
-- consisting of only whitespace.
--
-- It's not strictly necessary for this to be a part of this library, but
-- newline-delimited JSON is somewhat common in practice. It's nice to
-- have this here instead of having to reimplement it in a bunch of
-- different applications.
--
-- Note: To protect against malicious input, this reject byte sequences
-- with more than 10 million newlines. If this is causing a problem for
-- you, open an issue.
--
-- Other note: in the future, this function might be changed
-- transparently to parallelize the decoding of large input (at least
-- 1000 lines) with GHC sparks.
decodeNewlineDelimited :: Bytes -> Either SyntaxException (SmallArray Value)
-- | Encode a JSON syntax tree.
encode :: Value -> Builder
toChunks :: Value -> Chunks
toShortText :: Value -> ShortText
toText :: Value -> Text
toBytes :: Value -> Bytes
toByteArray :: Value -> ByteArray
-- | 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
int :: Int -> Value
int8 :: Int8 -> Value
int16 :: Int16 -> Value
int32 :: Int32 -> Value
int64 :: Int64 -> Value
word8 :: Word8 -> Value
word16 :: Word16 -> Value
word32 :: Word32 -> Value
word64 :: Word64 -> Value
bool :: Bool -> Value
text :: Text -> Value
shortText :: ShortText -> Value
-- | Construct a JSON array from a list of JSON values.
--
-- Unlike objectFromList, this is not currently equipped with a
-- rewrite rule.
arrayFromList :: [Value] -> Value
-- | Construct a JSON object from a list of members.
--
-- Note: When the argument is a list literal with 16 or fewer elements, a
-- rewrite rule transforms this into the appropriate objectN
-- function. When the argument is not a list literal, this function just
-- calls smallArrayFromList on the members, which has poor
-- performance.
objectFromList :: [Member] -> 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
-- | Construct a JSON object with thirteen members.
object13 :: Member -> Member -> Member -> Member -> Member -> Member -> Member -> Member -> Member -> Member -> Member -> Member -> Member -> Value
-- | Construct a JSON object with fourteen members.
object14 :: Member -> Member -> Member -> Member -> Member -> Member -> Member -> Member -> Member -> Member -> Member -> Member -> Member -> Member -> Value
-- | Construct a JSON object with fifteen members.
object15 :: Member -> Member -> Member -> Member -> Member -> Member -> Member -> Member -> Member -> Member -> Member -> Member -> Member -> Member -> Member -> Value
-- | Construct a JSON object with sixteen members.
object16 :: Member -> Member -> Member -> Member -> 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
instance Json.ToValue ()
instance Json.ToValue Json.Value
instance Json.ToValue Data.Number.Scientific.Scientific
instance Json.ToValue GHC.Types.Int
instance Json.ToValue GHC.Int.Int8
instance Json.ToValue GHC.Int.Int16
instance Json.ToValue GHC.Int.Int32
instance Json.ToValue GHC.Int.Int64
instance Json.ToValue GHC.Word.Word8
instance Json.ToValue GHC.Word.Word16
instance Json.ToValue GHC.Word.Word32
instance Json.ToValue GHC.Word.Word64
instance Json.ToValue Data.Text.Short.Internal.ShortText
instance Json.ToValue Data.Text.Internal.Text
instance Json.ToValue GHC.Types.Bool
instance Json.ToValue GHC.Types.Word
instance Json.ToValue a => Json.ToValue [a]
instance Json.ToValue a => Json.ToValue (Data.Primitive.SmallArray.SmallArray a)
instance Json.ToValue a => Json.ToValue (Data.Primitive.Array.Array a)
instance (Data.Primitive.Types.Prim a, Json.ToValue a) => Json.ToValue (Data.Primitive.PrimArray.PrimArray a)
-- | 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