-- | The JSON tree.
--
-- One type, six constructors, no policy. Duplicate object keys are preserved
-- in source order; what to do about them is a consumer decision, not a
-- parsing one.
module Circuit.Parser.Json.Value
  ( Json (..),
  )
where

import Data.Scientific (Scientific)
import Data.Text (Text)
import Data.Vector (Vector)

-- | A JSON value.
--
-- 'JNumber' is exact ('Scientific': coefficient times ten to an exponent),
-- so parsing loses nothing. 'JObject' is an association list in source
-- order.
data Json
  = JNull
  | JBool !Bool
  | JNumber !Scientific
  | JString !Text
  | JArray (Vector Json)
  | JObject [(Text, Json)]
  deriving (Json -> Json -> Bool
(Json -> Json -> Bool) -> (Json -> Json -> Bool) -> Eq Json
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Json -> Json -> Bool
== :: Json -> Json -> Bool
$c/= :: Json -> Json -> Bool
/= :: Json -> Json -> Bool
Eq, Int -> Json -> ShowS
[Json] -> ShowS
Json -> String
(Int -> Json -> ShowS)
-> (Json -> String) -> ([Json] -> ShowS) -> Show Json
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Json -> ShowS
showsPrec :: Int -> Json -> ShowS
$cshow :: Json -> String
show :: Json -> String
$cshowList :: [Json] -> ShowS
showList :: [Json] -> ShowS
Show)