conferer-aeson-1.0.0.0: conferer's source for reading json files
Copyright(c) 2019 Lucas David Traverso
LicenseMPL-2.0
MaintainerLucas David Traverso <lucas6246@gmail.com>
Stabilitystable
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

Conferer.Source.Aeson

Description

Source for json config files using Aeson

Synopsis

Documentation

data JsonSource Source #

Source that read a config file as json and uses that value in a way that makes sense for Conferer but doesn't respect json perfectly.

Constructors

JsonSource 

Fields

Instances

Instances details
Eq JsonSource Source # 
Instance details

Defined in Conferer.Source.Aeson

Show JsonSource Source # 
Instance details

Defined in Conferer.Source.Aeson

IsSource JsonSource Source # 
Instance details

Defined in Conferer.Source.Aeson

fromConfig :: Key -> SourceCreator Source #

Create a SourceCreator which uses files with config/{env}.json template and then uses fromFilePath

fromFilePath :: FilePath -> IO Source Source #

Create a Source from a filepath

If the file is not present it will behave as if it had no keys.

If the file doesn't have valid json it will throw an error.

fromValue :: Value -> Source Source #

Create a Source from a json value, never fails.

traverseJSON :: Key -> Value -> Maybe Value Source #

Traverse a Value using a Key to get a Value.

This function can nest objects and arrays when keys are nested

traverseJSON "a.b" {a: {b: 12}} == Just "12"
traverseJSON "a.b" {a: {b: false}} == Just "false"
traverseJSON "a" {a: {b: false}} == Nothing
traverseJSON "1" [false, true] == Just "true"
traverseJSON "0.a" [{a: "hi"}] == Just "hi"
traverseJSON "0" [] == Nothing

listKeysInJSON :: Value -> [Key] Source #

Get the list of available keys inside a json value

valueToText :: Value -> Maybe Text Source #

Turn json Value into Text to return that key

boolToString :: Bool -> Text Source #

Turn a Bool into a Text

resultToMaybe :: Result a -> Maybe a Source #

Because we use an old version of aeson