| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Data.Yaml
Description
Provides a high-level interface for processing YAML files.
This module reuses most of the infrastructure from the aeson package.
This means that you can use all of the existing tools for JSON
processing for processing YAML files. As a result, much of the
documentation below mentions JSON; do not let that confuse you, it's
intentional.
For the most part, YAML content translates directly into JSON, and therefore there is very little data loss. If you need to deal with YAML more directly (e.g., directly deal with aliases), you should use the Text.Libyaml module instead.
For documentation on the aeson types, functions, classes, and
operators, please see the Data.Aeson module of the aeson package.
Look in the examples directory of the source repository for some initial pointers on how to use this library.
Synopsis
- encode :: ToJSON a => a -> ByteString
- encodeWith :: ToJSON a => EncodeOptions -> a -> ByteString
- encodeFile :: ToJSON a => FilePath -> a -> IO ()
- encodeFileWith :: ToJSON a => EncodeOptions -> FilePath -> a -> IO ()
- decodeEither' :: FromJSON a => ByteString -> Either ParseException a
- decodeFileEither :: FromJSON a => FilePath -> IO (Either ParseException a)
- decodeFileWithWarnings :: FromJSON a => FilePath -> IO (Either ParseException ([Warning], a))
- decodeThrow :: (MonadThrow m, FromJSON a) => ByteString -> m a
- decodeFileThrow :: (MonadIO m, FromJSON a) => FilePath -> m a
- decodeAllEither' :: FromJSON a => ByteString -> Either ParseException [a]
- decodeAllFileEither :: FromJSON a => FilePath -> IO (Either ParseException [a])
- decodeAllFileWithWarnings :: FromJSON a => FilePath -> IO (Either ParseException ([Warning], [a]))
- decodeAllThrow :: (MonadThrow m, FromJSON a) => ByteString -> m [a]
- decodeAllFileThrow :: (MonadIO m, FromJSON a) => FilePath -> m [a]
- decodeHelper :: FromJSON a => ConduitM () Event Parse () -> IO (Either ParseException ([Warning], Either String a))
- data Value
- data Parser a
- type Object = KeyMap Value
- type Array = Vector Value
- data ParseException
- = NonScalarKey
- | UnknownAlias {
- _anchorName :: AnchorName
- | UnexpectedEvent { }
- | InvalidYaml (Maybe YamlException)
- | MultipleDocuments
- | AesonException String
- | OtherParseException SomeException
- | NonStringKey JSONPath
- | NonStringKeyAlias AnchorName Value
- | CyclicIncludes
- | LoadSettingsException FilePath ParseException
- prettyPrintParseException :: ParseException -> String
- data YamlException
- data YamlMark = YamlMark {}
- object :: [Pair] -> Value
- array :: [Value] -> Value
- (.=) :: (KeyValue e kv, ToJSON v) => Key -> v -> kv
- (.:) :: FromJSON a => Object -> Key -> Parser a
- (.:?) :: FromJSON a => Object -> Key -> Parser (Maybe a)
- (.!=) :: Parser (Maybe a) -> a -> Parser a
- withObject :: String -> (Object -> Parser a) -> Value -> Parser a
- withText :: String -> (Text -> Parser a) -> Value -> Parser a
- withArray :: String -> (Array -> Parser a) -> Value -> Parser a
- withScientific :: String -> (Scientific -> Parser a) -> Value -> Parser a
- withBool :: String -> (Bool -> Parser a) -> Value -> Parser a
- parseMonad :: MonadFail m => (a -> Parser b) -> a -> m b
- parseEither :: (a -> Parser b) -> a -> Either String b
- parseMaybe :: (a -> Parser b) -> a -> Maybe b
- class ToJSON a where
- toJSON :: a -> Value
- toEncoding :: a -> Encoding
- toJSONList :: [a] -> Value
- toEncodingList :: [a] -> Encoding
- omitField :: a -> Bool
- class FromJSON a where
- parseJSON :: Value -> Parser a
- parseJSONList :: Value -> Parser [a]
- omittedField :: Maybe a
- isSpecialString :: Text -> Bool
- data EncodeOptions
- defaultEncodeOptions :: EncodeOptions
- defaultStringStyle :: StringStyle
- setStringStyle :: (Text -> (Tag, Style)) -> EncodeOptions -> EncodeOptions
- setFormat :: FormatOptions -> EncodeOptions -> EncodeOptions
- data FormatOptions
- defaultFormatOptions :: FormatOptions
- setWidth :: Maybe Int -> FormatOptions -> FormatOptions
- decode :: FromJSON a => ByteString -> Maybe a
- decodeFile :: FromJSON a => FilePath -> IO (Maybe a)
- decodeEither :: FromJSON a => ByteString -> Either String a
Encoding
encode :: ToJSON a => a -> ByteString Source #
Encode a value into its YAML representation.
encodeWith :: ToJSON a => EncodeOptions -> a -> ByteString Source #
Encode a value into its YAML representation with custom styling.
Since: 0.10.2.0
encodeFile :: ToJSON a => FilePath -> a -> IO () Source #
Encode a value into its YAML representation and save to the given file.
encodeFileWith :: ToJSON a => EncodeOptions -> FilePath -> a -> IO () Source #
Encode a value into its YAML representation with custom styling and save to the given file.
Since: 0.10.2.0
Decoding
decodeEither' :: FromJSON a => ByteString -> Either ParseException a Source #
More helpful version of decodeEither which returns the YamlException.
Since: 0.8.3
decodeFileEither :: FromJSON a => FilePath -> IO (Either ParseException a) Source #
A version of decodeFile which should not throw runtime exceptions.
Since: 0.8.4
decodeFileWithWarnings :: FromJSON a => FilePath -> IO (Either ParseException ([Warning], a)) Source #
A version of decodeFileEither that returns warnings along with the parse
result.
Since: 0.10.0
decodeThrow :: (MonadThrow m, FromJSON a) => ByteString -> m a Source #
A version of decodeEither' lifted to MonadThrow
Since: 0.8.31
decodeFileThrow :: (MonadIO m, FromJSON a) => FilePath -> m a Source #
A version of decodeFileEither lifted to MonadIO
Since: 0.8.31
Decoding multiple documents
For situations where we need to be able to parse multiple documents separated by `---` in a YAML stream, these functions decode a list of values rather than a single value.
decodeAllEither' :: FromJSON a => ByteString -> Either ParseException [a] Source #
Like decodeEither', but decode multiple documents.
Since: 0.11.5.0
decodeAllFileEither :: FromJSON a => FilePath -> IO (Either ParseException [a]) Source #
Like decodeFileEither, but decode multiple documents.
Since: 0.11.5.0
decodeAllFileWithWarnings :: FromJSON a => FilePath -> IO (Either ParseException ([Warning], [a])) Source #
Like decodeFileWithWarnings, but decode multiple documents.
Since: 0.11.5.0
decodeAllThrow :: (MonadThrow m, FromJSON a) => ByteString -> m [a] Source #
Like decodeThrow, but decode multiple documents.
Since: 0.11.5.0
decodeAllFileThrow :: (MonadIO m, FromJSON a) => FilePath -> m [a] Source #
Like decodeFileThrow, but decode multiple documents.
Since: 0.11.5.0
More control over decoding
decodeHelper :: FromJSON a => ConduitM () Event Parse () -> IO (Either ParseException ([Warning], Either String a)) Source #
Types
Instances
| Arbitrary Value | |
| CoArbitrary Value | |
Defined in Data.Aeson.Types.Internal Methods coarbitrary :: Value -> Gen b -> Gen b | |
| Function Value | |
Defined in Data.Aeson.Types.Internal | |
| FromJSON Value | |
Defined in Data.Aeson.Types.FromJSON | |
| ToJSON Value | |
Defined in Data.Aeson.Types.ToJSON | |
| Data Value | |
Defined in Data.Aeson.Types.Internal Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Value -> c Value Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Value Source # toConstr :: Value -> Constr Source # dataTypeOf :: Value -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Value) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Value) Source # gmapT :: (forall b. Data b => b -> b) -> Value -> Value Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Value -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Value -> r Source # gmapQ :: (forall d. Data d => d -> u) -> Value -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> Value -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Value -> m Value Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Value -> m Value Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Value -> m Value Source # | |
| IsString Value | |
Defined in Data.Aeson.Types.Internal Methods fromString :: String -> Value Source # | |
| Generic Value | |
| Read Value | |
| Show Value | |
| NFData Value | |
Defined in Data.Aeson.Types.Internal | |
| Eq Value | |
| Ord Value | |
Defined in Data.Aeson.Types.Internal | |
| Hashable Value | |
Defined in Data.Aeson.Types.Internal | |
| KeyValue Encoding Series | |
Defined in Data.Aeson.Types.ToJSON Methods (.=) :: ToJSON v => Key -> v -> Series # explicitToField :: (v -> Encoding) -> Key -> v -> Series | |
| KeyValueOmit Encoding Series | |
Defined in Data.Aeson.Types.ToJSON Methods (.?=) :: ToJSON v => Key -> v -> Series explicitToFieldOmit :: (v -> Bool) -> (v -> Encoding) -> Key -> v -> Series | |
| Lift Value | |
| (GToJSON' Encoding arity a, ConsToJSON Encoding arity a, Constructor c) => SumToJSON' TwoElemArray Encoding arity (C1 c a) | |
Defined in Data.Aeson.Types.ToJSON Methods sumToJSON' :: Options -> ToArgs Encoding arity a0 -> C1 c a a0 -> Tagged TwoElemArray Encoding | |
| (GToJSON' Value arity a, ConsToJSON Value arity a, Constructor c) => SumToJSON' TwoElemArray Value arity (C1 c a) | |
Defined in Data.Aeson.Types.ToJSON Methods sumToJSON' :: Options -> ToArgs Value arity a0 -> C1 c a a0 -> Tagged TwoElemArray Value | |
| GToJSON' Encoding arity (U1 :: Type -> Type) | |
Defined in Data.Aeson.Types.ToJSON | |
| GToJSON' Encoding arity (V1 :: Type -> Type) | |
Defined in Data.Aeson.Types.ToJSON | |
| GToJSON' Value arity (U1 :: Type -> Type) | |
Defined in Data.Aeson.Types.ToJSON | |
| GToJSON' Value arity (V1 :: Type -> Type) | |
Defined in Data.Aeson.Types.ToJSON | |
| ToJSON1 f => GToJSON' Encoding One (Rec1 f) | |
Defined in Data.Aeson.Types.ToJSON | |
| ToJSON1 f => GToJSON' Value One (Rec1 f) | |
Defined in Data.Aeson.Types.ToJSON | |
| (EncodeProduct arity a, EncodeProduct arity b) => GToJSON' Encoding arity (a :*: b) | |
Defined in Data.Aeson.Types.ToJSON | |
| ToJSON a => GToJSON' Encoding arity (K1 i a :: Type -> Type) | |
Defined in Data.Aeson.Types.ToJSON | |
| (WriteProduct arity a, WriteProduct arity b, ProductSize a, ProductSize b) => GToJSON' Value arity (a :*: b) | |
Defined in Data.Aeson.Types.ToJSON | |
| ToJSON a => GToJSON' Value arity (K1 i a :: Type -> Type) | |
Defined in Data.Aeson.Types.ToJSON | |
| (ToJSON1 f, GToJSON' Encoding One g) => GToJSON' Encoding One (f :.: g) | |
Defined in Data.Aeson.Types.ToJSON | |
| (ToJSON1 f, GToJSON' Value One g) => GToJSON' Value One (f :.: g) | |
Defined in Data.Aeson.Types.ToJSON | |
| FromPairs Value (DList Pair) | |
Defined in Data.Aeson.Types.ToJSON | |
| value ~ Value => KeyValue Value (KeyMap value) | |
Defined in Data.Aeson.Types.ToJSON Methods (.=) :: ToJSON v => Key -> v -> KeyMap value # explicitToField :: (v -> Value) -> Key -> v -> KeyMap value | |
| value ~ Value => KeyValueOmit Value (KeyMap value) | |
Defined in Data.Aeson.Types.ToJSON Methods (.?=) :: ToJSON v => Key -> v -> KeyMap value explicitToFieldOmit :: (v -> Bool) -> (v -> Value) -> Key -> v -> KeyMap value | |
| v ~ Value => KeyValuePair v (DList Pair) | |
Defined in Data.Aeson.Types.ToJSON Methods pair :: Key -> v -> DList Pair | |
| (key ~ Key, value ~ Value) => KeyValue Value (key, value) | |
Defined in Data.Aeson.Types.ToJSON Methods (.=) :: ToJSON v => Key -> v -> (key, value) # explicitToField :: (v -> Value) -> Key -> v -> (key, value) | |
| type Rep Value | |
Defined in Data.Aeson.Types.Internal type Rep Value = D1 ('MetaData "Value" "Data.Aeson.Types.Internal" "aeson-2.2.3.0-FIuhcpStCJb6RwQN89Mekh" 'False) ((C1 ('MetaCons "Object" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Object)) :+: (C1 ('MetaCons "Array" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Array)) :+: C1 ('MetaCons "String" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Text)))) :+: (C1 ('MetaCons "Number" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Scientific)) :+: (C1 ('MetaCons "Bool" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Bool)) :+: C1 ('MetaCons "Null" 'PrefixI 'False) (U1 :: Type -> Type)))) | |
data ParseException Source #
Constructors
| NonScalarKey | |
| UnknownAlias | |
Fields
| |
| UnexpectedEvent | |
| InvalidYaml (Maybe YamlException) | |
| MultipleDocuments | |
| AesonException String | |
| OtherParseException SomeException | |
| NonStringKey JSONPath | |
| NonStringKeyAlias AnchorName Value | |
| CyclicIncludes | |
| LoadSettingsException FilePath ParseException | |
Instances
| Exception ParseException Source # | |
Defined in Data.Yaml.Internal Methods toException :: ParseException -> SomeException Source # fromException :: SomeException -> Maybe ParseException Source # | |
| Show ParseException Source # | |
Defined in Data.Yaml.Internal | |
prettyPrintParseException :: ParseException -> String Source #
Alternative to show to display a ParseException on the screen.
Instead of displaying the data constructors applied to their arguments,
a more textual output is returned. For example, instead of printing:
InvalidYaml (Just (YamlParseException {yamlProblem = "did not find expected ',' or '}'", yamlContext = "while parsing a flow mapping", yamlProblemMark = YamlMark {yamlIndex = 42, yamlLine = 2, yamlColumn = 12}})))It looks more pleasant to print:
YAML parse exception at line 2, column 12, while parsing a flow mapping: did not find expected ',' or '}'
Since 0.8.11
data YamlException #
Constructors
| YamlException String | |
| YamlParseException | |
Fields | |
Instances
| Exception YamlException | |
Defined in Text.Libyaml Methods toException :: YamlException -> SomeException Source # fromException :: SomeException -> Maybe YamlException Source # | |
| Show YamlException | |
Defined in Text.Libyaml | |
Constructors and accessors
With helpers (since 0.8.23)
Parsing
parseMonad :: MonadFail m => (a -> Parser b) -> a -> m b Source #
Deprecated: With the MonadFail split, this function is going to be removed in the future. Please migrate to parseEither.
parseEither :: (a -> Parser b) -> a -> Either String b #
parseMaybe :: (a -> Parser b) -> a -> Maybe b #
Classes
Minimal complete definition
Nothing
Instances
| ToJSON Key | |
Defined in Data.Aeson.Types.ToJSON Methods toEncoding :: Key -> Encoding # toJSONList :: [Key] -> Value # toEncodingList :: [Key] -> Encoding # | |
| ToJSON DotNetTime | |
Defined in Data.Aeson.Types.ToJSON Methods toJSON :: DotNetTime -> Value # toEncoding :: DotNetTime -> Encoding # toJSONList :: [DotNetTime] -> Value # toEncodingList :: [DotNetTime] -> Encoding # | |
| ToJSON Value | |
Defined in Data.Aeson.Types.ToJSON | |
| ToJSON All | |
Defined in Data.Aeson.Types.ToJSON | |
| ToJSON Any | |
Defined in Data.Aeson.Types.ToJSON | |
| ToJSON Version | |
Defined in Data.Aeson.Types.ToJSON | |
| ToJSON CTime | |
Defined in Data.Aeson.Types.ToJSON | |
| ToJSON Void | |
Defined in Data.Aeson.Types.ToJSON | |
| ToJSON Int16 | |
Defined in Data.Aeson.Types.ToJSON | |
| ToJSON Int32 | |
Defined in Data.Aeson.Types.ToJSON | |
| ToJSON Int64 | |
Defined in Data.Aeson.Types.ToJSON | |
| ToJSON Int8 | |
Defined in Data.Aeson.Types.ToJSON | |
| ToJSON Word16 | |
Defined in Data.Aeson.Types.ToJSON | |
| ToJSON Word32 | |
Defined in Data.Aeson.Types.ToJSON | |
| ToJSON Word64 | |
Defined in Data.Aeson.Types.ToJSON | |
| ToJSON Word8 | |
Defined in Data.Aeson.Types.ToJSON | |
| ToJSON IntSet | |
Defined in Data.Aeson.Types.ToJSON | |
| ToJSON Ordering | |
Defined in Data.Aeson.Types.ToJSON | |
| ToJSON URI | |
Defined in Data.Aeson.Types.ToJSON Methods toEncoding :: URI -> Encoding # toJSONList :: [URI] -> Value # toEncodingList :: [URI] -> Encoding # | |
| ToJSON Scientific | |
Defined in Data.Aeson.Types.ToJSON Methods toJSON :: Scientific -> Value # toEncoding :: Scientific -> Encoding # toJSONList :: [Scientific] -> Value # toEncodingList :: [Scientific] -> Encoding # | |
| ToJSON Text | |
Defined in Data.Aeson.Types.ToJSON | |
| ToJSON Text | |
Defined in Data.Aeson.Types.ToJSON | |
| ToJSON ShortText | |
Defined in Data.Aeson.Types.ToJSON Methods toJSON :: ShortText -> Value # toEncoding :: ShortText -> Encoding # toJSONList :: [ShortText] -> Value # toEncodingList :: [ShortText] -> Encoding # | |
| ToJSON CalendarDiffDays | |
Defined in Data.Aeson.Types.ToJSON Methods toJSON :: CalendarDiffDays -> Value # toEncoding :: CalendarDiffDays -> Encoding # toJSONList :: [CalendarDiffDays] -> Value # toEncodingList :: [CalendarDiffDays] -> Encoding # omitField :: CalendarDiffDays -> Bool # | |
| ToJSON Day | |
Defined in Data.Aeson.Types.ToJSON | |
| ToJSON Month | |
Defined in Data.Aeson.Types.ToJSON | |
| ToJSON Quarter | |
Defined in Data.Aeson.Types.ToJSON | |
| ToJSON QuarterOfYear | |
Defined in Data.Aeson.Types.ToJSON Methods toJSON :: QuarterOfYear -> Value # toEncoding :: QuarterOfYear -> Encoding # toJSONList :: [QuarterOfYear] -> Value # toEncodingList :: [QuarterOfYear] -> Encoding # omitField :: QuarterOfYear -> Bool # | |
| ToJSON DayOfWeek | |
Defined in Data.Aeson.Types.ToJSON | |
| ToJSON DiffTime | |
Defined in Data.Aeson.Types.ToJSON | |
| ToJSON NominalDiffTime | |
Defined in Data.Aeson.Types.ToJSON Methods toJSON :: NominalDiffTime -> Value # toEncoding :: NominalDiffTime -> Encoding # toJSONList :: [NominalDiffTime] -> Value # toEncodingList :: [NominalDiffTime] -> Encoding # omitField :: NominalDiffTime -> Bool # | |
| ToJSON SystemTime | |
Defined in Data.Aeson.Types.ToJSON Methods toJSON :: SystemTime -> Value # toEncoding :: SystemTime -> Encoding # toJSONList :: [SystemTime] -> Value # toEncodingList :: [SystemTime] -> Encoding # omitField :: SystemTime -> Bool # | |
| ToJSON UTCTime | |
Defined in Data.Aeson.Types.ToJSON | |
| ToJSON CalendarDiffTime | |
Defined in Data.Aeson.Types.ToJSON Methods toJSON :: CalendarDiffTime -> Value # toEncoding :: CalendarDiffTime -> Encoding # toJSONList :: [CalendarDiffTime] -> Value # toEncodingList :: [CalendarDiffTime] -> Encoding # omitField :: CalendarDiffTime -> Bool # | |
| ToJSON LocalTime | |
Defined in Data.Aeson.Types.ToJSON | |
| ToJSON TimeOfDay | |
Defined in Data.Aeson.Types.ToJSON | |
| ToJSON ZonedTime | |
Defined in Data.Aeson.Types.ToJSON | |
| ToJSON UUID | |
Defined in Data.Aeson.Types.ToJSON Methods toEncoding :: UUID -> Encoding # toJSONList :: [UUID] -> Value # toEncodingList :: [UUID] -> Encoding # | |
| ToJSON Integer | |
Defined in Data.Aeson.Types.ToJSON | |
| ToJSON Natural | |
Defined in Data.Aeson.Types.ToJSON | |
| ToJSON () | |
Defined in Data.Aeson.Types.ToJSON Methods toEncoding :: () -> Encoding # toJSONList :: [()] -> Value # toEncodingList :: [()] -> Encoding # | |
| ToJSON Bool | |
Defined in Data.Aeson.Types.ToJSON | |
| ToJSON Char | |
Defined in Data.Aeson.Types.ToJSON | |
| ToJSON Double | |
Defined in Data.Aeson.Types.ToJSON | |
| ToJSON Float | |
Defined in Data.Aeson.Types.ToJSON | |
| ToJSON Int | |
Defined in Data.Aeson.Types.ToJSON | |
| ToJSON Word | |
Defined in Data.Aeson.Types.ToJSON | |
| ToJSON v => ToJSON (KeyMap v) | |
Defined in Data.Aeson.Types.ToJSON Methods toEncoding :: KeyMap v -> Encoding # toJSONList :: [KeyMap v] -> Value # toEncodingList :: [KeyMap v] -> Encoding # | |
| ToJSON a => ToJSON (Identity a) | |
Defined in Data.Aeson.Types.ToJSON | |
| ToJSON a => ToJSON (First a) | |
Defined in Data.Aeson.Types.ToJSON | |
| ToJSON a => ToJSON (Last a) | |
Defined in Data.Aeson.Types.ToJSON | |
| ToJSON a => ToJSON (Down a) | |
Defined in Data.Aeson.Types.ToJSON | |
| ToJSON a => ToJSON (First a) | |
Defined in Data.Aeson.Types.ToJSON | |
| ToJSON a => ToJSON (Last a) | |
Defined in Data.Aeson.Types.ToJSON | |
| ToJSON a => ToJSON (Max a) | |
Defined in Data.Aeson.Types.ToJSON | |
| ToJSON a => ToJSON (Min a) | |
Defined in Data.Aeson.Types.ToJSON | |
| ToJSON a => ToJSON (WrappedMonoid a) | |
Defined in Data.Aeson.Types.ToJSON Methods toJSON :: WrappedMonoid a -> Value # toEncoding :: WrappedMonoid a -> Encoding # toJSONList :: [WrappedMonoid a] -> Value # toEncodingList :: [WrappedMonoid a] -> Encoding # omitField :: WrappedMonoid a -> Bool # | |
| ToJSON a => ToJSON (Dual a) | |
Defined in Data.Aeson.Types.ToJSON | |
| ToJSON a => ToJSON (Product a) | |
Defined in Data.Aeson.Types.ToJSON | |
| ToJSON a => ToJSON (Sum a) | |
Defined in Data.Aeson.Types.ToJSON | |
| ToJSON a => ToJSON (NonEmpty a) | |
Defined in Data.Aeson.Types.ToJSON | |
| (Generic a, GToJSON' Value Zero (Rep a), GToJSON' Encoding Zero (Rep a)) => ToJSON (Generically a) | |
Defined in Data.Aeson.Types.ToJSON Methods toJSON :: Generically a -> Value # toEncoding :: Generically a -> Encoding # toJSONList :: [Generically a] -> Value # toEncodingList :: [Generically a] -> Encoding # omitField :: Generically a -> Bool # | |
| (ToJSON a, Integral a) => ToJSON (Ratio a) | |
Defined in Data.Aeson.Types.ToJSON | |
| ToJSON a => ToJSON (IntMap a) | |
Defined in Data.Aeson.Types.ToJSON | |
| ToJSON a => ToJSON (Seq a) | |
Defined in Data.Aeson.Types.ToJSON | |
| ToJSON a => ToJSON (Set a) | |
Defined in Data.Aeson.Types.ToJSON | |
| ToJSON v => ToJSON (Tree v) | |
Defined in Data.Aeson.Types.ToJSON | |
| ToJSON1 f => ToJSON (Fix f) | |
Defined in Data.Aeson.Types.ToJSON Methods toEncoding :: Fix f -> Encoding # toJSONList :: [Fix f] -> Value # toEncodingList :: [Fix f] -> Encoding # | |
| (ToJSON1 f, Functor f) => ToJSON (Mu f) | |
Defined in Data.Aeson.Types.ToJSON Methods toEncoding :: Mu f -> Encoding # toJSONList :: [Mu f] -> Value # toEncodingList :: [Mu f] -> Encoding # | |
| (ToJSON1 f, Functor f) => ToJSON (Nu f) | |
Defined in Data.Aeson.Types.ToJSON Methods toEncoding :: Nu f -> Encoding # toJSONList :: [Nu f] -> Value # toEncodingList :: [Nu f] -> Encoding # | |
| ToJSON a => ToJSON (DNonEmpty a) | |
Defined in Data.Aeson.Types.ToJSON Methods toJSON :: DNonEmpty a -> Value # toEncoding :: DNonEmpty a -> Encoding # toJSONList :: [DNonEmpty a] -> Value # toEncodingList :: [DNonEmpty a] -> Encoding # | |
| ToJSON a => ToJSON (DList a) | |
Defined in Data.Aeson.Types.ToJSON Methods toEncoding :: DList a -> Encoding # toJSONList :: [DList a] -> Value # toEncodingList :: [DList a] -> Encoding # | |
| ToJSON a => ToJSON (Array a) | |
Defined in Data.Aeson.Types.ToJSON Methods toEncoding :: Array a -> Encoding # toJSONList :: [Array a] -> Value # toEncodingList :: [Array a] -> Encoding # | |
| (Prim a, ToJSON a) => ToJSON (PrimArray a) | |
Defined in Data.Aeson.Types.ToJSON Methods toJSON :: PrimArray a -> Value # toEncoding :: PrimArray a -> Encoding # toJSONList :: [PrimArray a] -> Value # toEncodingList :: [PrimArray a] -> Encoding # | |
| ToJSON a => ToJSON (SmallArray a) | |
Defined in Data.Aeson.Types.ToJSON Methods toJSON :: SmallArray a -> Value # toEncoding :: SmallArray a -> Encoding # toJSONList :: [SmallArray a] -> Value # toEncodingList :: [SmallArray a] -> Encoding # | |
| ToJSON a => ToJSON (Maybe a) | |
Defined in Data.Aeson.Types.ToJSON Methods toEncoding :: Maybe a -> Encoding # toJSONList :: [Maybe a] -> Value # toEncodingList :: [Maybe a] -> Encoding # | |
| ToJSON a => ToJSON (HashSet a) | |
Defined in Data.Aeson.Types.ToJSON Methods toJSON :: HashSet a -> Value # toEncoding :: HashSet a -> Encoding # toJSONList :: [HashSet a] -> Value # toEncodingList :: [HashSet a] -> Encoding # | |
| ToJSON a => ToJSON (Vector a) | |
Defined in Data.Aeson.Types.ToJSON Methods toEncoding :: Vector a -> Encoding # toJSONList :: [Vector a] -> Value # toEncodingList :: [Vector a] -> Encoding # | |
| (Prim a, ToJSON a) => ToJSON (Vector a) | |
Defined in Data.Aeson.Types.ToJSON Methods toEncoding :: Vector a -> Encoding # toJSONList :: [Vector a] -> Value # toEncodingList :: [Vector a] -> Encoding # | |
| (Storable a, ToJSON a) => ToJSON (Vector a) | |
Defined in Data.Aeson.Types.ToJSON Methods toEncoding :: Vector a -> Encoding # toJSONList :: [Vector a] -> Value # toEncodingList :: [Vector a] -> Encoding # | |
| (Vector Vector a, ToJSON a) => ToJSON (Vector a) | |
Defined in Data.Aeson.Types.ToJSON Methods toEncoding :: Vector a -> Encoding # toJSONList :: [Vector a] -> Value # toEncodingList :: [Vector a] -> Encoding # | |
| ToJSON a => ToJSON (Maybe a) | |
Defined in Data.Aeson.Types.ToJSON | |
| ToJSON a => ToJSON (a) | |
Defined in Data.Aeson.Types.ToJSON Methods toEncoding :: (a) -> Encoding # toJSONList :: [(a)] -> Value # toEncodingList :: [(a)] -> Encoding # | |
| ToJSON a => ToJSON [a] | |
Defined in Data.Aeson.Types.ToJSON Methods toEncoding :: [a] -> Encoding # toJSONList :: [[a]] -> Value # toEncodingList :: [[a]] -> Encoding # | |
| (ToJSON a, ToJSON b) => ToJSON (Either a b) | |
Defined in Data.Aeson.Types.ToJSON | |
| HasResolution a => ToJSON (Fixed a) | |
Defined in Data.Aeson.Types.ToJSON | |
| ToJSON (Proxy a) | |
Defined in Data.Aeson.Types.ToJSON | |
| (ToJSON v, ToJSONKey k) => ToJSON (Map k v) | |
Defined in Data.Aeson.Types.ToJSON | |
| (ToJSON a, ToJSON b) => ToJSON (Either a b) | |
Defined in Data.Aeson.Types.ToJSON Methods toJSON :: Either a b -> Value # toEncoding :: Either a b -> Encoding # toJSONList :: [Either a b] -> Value # toEncodingList :: [Either a b] -> Encoding # | |
| (ToJSON a, ToJSON b) => ToJSON (These a b) | |
Defined in Data.Aeson.Types.ToJSON Methods toJSON :: These a b -> Value # toEncoding :: These a b -> Encoding # toJSONList :: [These a b] -> Value # toEncodingList :: [These a b] -> Encoding # | |
| (ToJSON a, ToJSON b) => ToJSON (Pair a b) | |
Defined in Data.Aeson.Types.ToJSON Methods toEncoding :: Pair a b -> Encoding # toJSONList :: [Pair a b] -> Value # toEncodingList :: [Pair a b] -> Encoding # | |
| (ToJSON a, ToJSON b) => ToJSON (These a b) | |
Defined in Data.Aeson.Types.ToJSON Methods toJSON :: These a b -> Value # toEncoding :: These a b -> Encoding # toJSONList :: [These a b] -> Value # toEncodingList :: [These a b] -> Encoding # | |
| (ToJSON v, ToJSONKey k) => ToJSON (HashMap k v) | |
Defined in Data.Aeson.Types.ToJSON Methods toJSON :: HashMap k v -> Value # toEncoding :: HashMap k v -> Encoding # toJSONList :: [HashMap k v] -> Value # toEncodingList :: [HashMap k v] -> Encoding # | |
| (ToJSON a, ToJSON b) => ToJSON (a, b) | |
Defined in Data.Aeson.Types.ToJSON Methods toEncoding :: (a, b) -> Encoding # toJSONList :: [(a, b)] -> Value # toEncodingList :: [(a, b)] -> Encoding # | |
| ToJSON a => ToJSON (Const a b) | |
Defined in Data.Aeson.Types.ToJSON | |
| ToJSON b => ToJSON (Tagged a b) | |
Defined in Data.Aeson.Types.ToJSON Methods toJSON :: Tagged a b -> Value # toEncoding :: Tagged a b -> Encoding # toJSONList :: [Tagged a b] -> Value # toEncodingList :: [Tagged a b] -> Encoding # | |
| (ToJSON1 f, ToJSON1 g, ToJSON a) => ToJSON (These1 f g a) | |
Defined in Data.Aeson.Types.ToJSON Methods toJSON :: These1 f g a -> Value # toEncoding :: These1 f g a -> Encoding # toJSONList :: [These1 f g a] -> Value # toEncodingList :: [These1 f g a] -> Encoding # | |
| (ToJSON a, ToJSON b, ToJSON c) => ToJSON (a, b, c) | |
Defined in Data.Aeson.Types.ToJSON Methods toJSON :: (a, b, c) -> Value # toEncoding :: (a, b, c) -> Encoding # toJSONList :: [(a, b, c)] -> Value # toEncodingList :: [(a, b, c)] -> Encoding # | |
| (ToJSON1 f, ToJSON1 g, ToJSON a) => ToJSON (Product f g a) | |
Defined in Data.Aeson.Types.ToJSON | |
| (ToJSON1 f, ToJSON1 g, ToJSON a) => ToJSON (Sum f g a) | |
Defined in Data.Aeson.Types.ToJSON | |
| (ToJSON a, ToJSON b, ToJSON c, ToJSON d) => ToJSON (a, b, c, d) | |
Defined in Data.Aeson.Types.ToJSON Methods toJSON :: (a, b, c, d) -> Value # toEncoding :: (a, b, c, d) -> Encoding # toJSONList :: [(a, b, c, d)] -> Value # toEncodingList :: [(a, b, c, d)] -> Encoding # | |
| (ToJSON1 f, ToJSON1 g, ToJSON a) => ToJSON (Compose f g a) | |
Defined in Data.Aeson.Types.ToJSON | |
| (ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e) => ToJSON (a, b, c, d, e) | |
Defined in Data.Aeson.Types.ToJSON Methods toJSON :: (a, b, c, d, e) -> Value # toEncoding :: (a, b, c, d, e) -> Encoding # toJSONList :: [(a, b, c, d, e)] -> Value # toEncodingList :: [(a, b, c, d, e)] -> Encoding # | |
| (ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f) => ToJSON (a, b, c, d, e, f) | |
Defined in Data.Aeson.Types.ToJSON Methods toJSON :: (a, b, c, d, e, f) -> Value # toEncoding :: (a, b, c, d, e, f) -> Encoding # toJSONList :: [(a, b, c, d, e, f)] -> Value # toEncodingList :: [(a, b, c, d, e, f)] -> Encoding # | |
| (ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f, ToJSON g) => ToJSON (a, b, c, d, e, f, g) | |
Defined in Data.Aeson.Types.ToJSON Methods toJSON :: (a, b, c, d, e, f, g) -> Value # toEncoding :: (a, b, c, d, e, f, g) -> Encoding # toJSONList :: [(a, b, c, d, e, f, g)] -> Value # toEncodingList :: [(a, b, c, d, e, f, g)] -> Encoding # | |
| (ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f, ToJSON g, ToJSON h) => ToJSON (a, b, c, d, e, f, g, h) | |
Defined in Data.Aeson.Types.ToJSON Methods toJSON :: (a, b, c, d, e, f, g, h) -> Value # toEncoding :: (a, b, c, d, e, f, g, h) -> Encoding # toJSONList :: [(a, b, c, d, e, f, g, h)] -> Value # toEncodingList :: [(a, b, c, d, e, f, g, h)] -> Encoding # | |
| (ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f, ToJSON g, ToJSON h, ToJSON i) => ToJSON (a, b, c, d, e, f, g, h, i) | |
Defined in Data.Aeson.Types.ToJSON Methods toJSON :: (a, b, c, d, e, f, g, h, i) -> Value # toEncoding :: (a, b, c, d, e, f, g, h, i) -> Encoding # toJSONList :: [(a, b, c, d, e, f, g, h, i)] -> Value # toEncodingList :: [(a, b, c, d, e, f, g, h, i)] -> Encoding # | |
| (ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f, ToJSON g, ToJSON h, ToJSON i, ToJSON j) => ToJSON (a, b, c, d, e, f, g, h, i, j) | |
Defined in Data.Aeson.Types.ToJSON Methods toJSON :: (a, b, c, d, e, f, g, h, i, j) -> Value # toEncoding :: (a, b, c, d, e, f, g, h, i, j) -> Encoding # toJSONList :: [(a, b, c, d, e, f, g, h, i, j)] -> Value # toEncodingList :: [(a, b, c, d, e, f, g, h, i, j)] -> Encoding # | |
| (ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f, ToJSON g, ToJSON h, ToJSON i, ToJSON j, ToJSON k) => ToJSON (a, b, c, d, e, f, g, h, i, j, k) | |
Defined in Data.Aeson.Types.ToJSON Methods toJSON :: (a, b, c, d, e, f, g, h, i, j, k) -> Value # toEncoding :: (a, b, c, d, e, f, g, h, i, j, k) -> Encoding # toJSONList :: [(a, b, c, d, e, f, g, h, i, j, k)] -> Value # toEncodingList :: [(a, b, c, d, e, f, g, h, i, j, k)] -> Encoding # | |
| (ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f, ToJSON g, ToJSON h, ToJSON i, ToJSON j, ToJSON k, ToJSON l) => ToJSON (a, b, c, d, e, f, g, h, i, j, k, l) | |
Defined in Data.Aeson.Types.ToJSON Methods toJSON :: (a, b, c, d, e, f, g, h, i, j, k, l) -> Value # toEncoding :: (a, b, c, d, e, f, g, h, i, j, k, l) -> Encoding # toJSONList :: [(a, b, c, d, e, f, g, h, i, j, k, l)] -> Value # toEncodingList :: [(a, b, c, d, e, f, g, h, i, j, k, l)] -> Encoding # | |
| (ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f, ToJSON g, ToJSON h, ToJSON i, ToJSON j, ToJSON k, ToJSON l, ToJSON m) => ToJSON (a, b, c, d, e, f, g, h, i, j, k, l, m) | |
Defined in Data.Aeson.Types.ToJSON Methods toJSON :: (a, b, c, d, e, f, g, h, i, j, k, l, m) -> Value # toEncoding :: (a, b, c, d, e, f, g, h, i, j, k, l, m) -> Encoding # toJSONList :: [(a, b, c, d, e, f, g, h, i, j, k, l, m)] -> Value # toEncodingList :: [(a, b, c, d, e, f, g, h, i, j, k, l, m)] -> Encoding # omitField :: (a, b, c, d, e, f, g, h, i, j, k, l, m) -> Bool # | |
| (ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f, ToJSON g, ToJSON h, ToJSON i, ToJSON j, ToJSON k, ToJSON l, ToJSON m, ToJSON n) => ToJSON (a, b, c, d, e, f, g, h, i, j, k, l, m, n) | |
Defined in Data.Aeson.Types.ToJSON Methods toJSON :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n) -> Value # toEncoding :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n) -> Encoding # toJSONList :: [(a, b, c, d, e, f, g, h, i, j, k, l, m, n)] -> Value # toEncodingList :: [(a, b, c, d, e, f, g, h, i, j, k, l, m, n)] -> Encoding # omitField :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n) -> Bool # | |
| (ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f, ToJSON g, ToJSON h, ToJSON i, ToJSON j, ToJSON k, ToJSON l, ToJSON m, ToJSON n, ToJSON o) => ToJSON (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) | |
Defined in Data.Aeson.Types.ToJSON Methods toJSON :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -> Value # toEncoding :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -> Encoding # toJSONList :: [(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)] -> Value # toEncodingList :: [(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)] -> Encoding # omitField :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -> Bool # | |
Minimal complete definition
Nothing
Methods
parseJSON :: Value -> Parser a #
parseJSONList :: Value -> Parser [a] #
omittedField :: Maybe a #
Instances
Custom encoding
isSpecialString :: Text -> Bool Source #
Determine whether a string must be quoted in YAML and can't appear as plain text.
Useful if you want to use setStringStyle.
Since: 0.10.2.0
data EncodeOptions Source #
Since: 0.10.2.0
defaultEncodeOptions :: EncodeOptions Source #
Since: 0.10.2.0
defaultStringStyle :: StringStyle Source #
Since: 0.11.2.0
setStringStyle :: (Text -> (Tag, Style)) -> EncodeOptions -> EncodeOptions Source #
Set the string style in the encoded YAML. This is a function that decides for each string the type of YAML string to output.
WARNING: You must ensure that special strings (like "yes"/"no"/"null"/"1234") are not encoded with the Plain style, because
then they will be decoded as boolean, null or numeric values. You can use isSpecialString to detect them.
By default, strings are encoded as follows:
- Any string containing a newline character uses the
Literalstyle - Otherwise, any special string (see
isSpecialString) usesSingleQuoted - Otherwise, use
Plain
Since: 0.10.2.0
setFormat :: FormatOptions -> EncodeOptions -> EncodeOptions Source #
Set the encoding formatting for the encoded YAML. By default, this is defaultFormatOptions.
Since: 0.10.2.0
data FormatOptions #
setWidth :: Maybe Int -> FormatOptions -> FormatOptions #
Deprecated
decode :: FromJSON a => ByteString -> Maybe a Source #
Deprecated: Please use decodeEither or decodeThrow, which provide information on how the decode failed
decodeFile :: FromJSON a => FilePath -> IO (Maybe a) Source #
Deprecated: Please use decodeFileEither, which does not confused type-directed and runtime exceptions.
decodeEither :: FromJSON a => ByteString -> Either String a Source #
Deprecated: Please use decodeEither' or decodeThrow, which provide more useful failures