aeson-helper-0.2.0.0: Aeson helper func
Safe HaskellNone
LanguageHaskell2010

Data.Aeson.Helper

Synopsis

Documentation

replace :: Key -> Key -> Value -> Value Source #

Replace JSON key to a new key

>>> replace "okey" "nkey" (object [ "okey" := "value" ])
Object (fromList [("nkey",String "value")])
>>> replace "okey" "nkey" (String "value")
String "value"

union :: Value -> Value -> Value Source #

Union two JSON

>>> union (object ["key1" .= "value1"]) (object ["key2" .= "value2"])
Object (fromList [("key2",String "value2"),("key1",String "value1")])
>>> union (object ["key1" .= "value1"]) (object ["key1" .= "value2"])
Object (fromList [("key1",String "value1")])
>>> union Null (object ["key2" .= "value2"])
Object (fromList [("key2",String "value2")])
>>> union (object ["key1" .= "value1"]) Null
Object (fromList [("key1",String "value1")])

difference :: Value -> Value -> Value Source #

Difference two JSON

>>> difference  (object ["key1" .= "value1", "key2" .= "value2"]) (object ["key1" .= Null])
Object (fromList [("key2",String "value2")])

pick :: [Text] -> Value -> Value Source #

Pick a value from JSON

>>> pick ["key1"] $ object ["key1" .= "value1", "key2" .= "value2", "key3" .= "value3"]
Object (fromList [("key1",String "value1")])
>>> pick ["key1", "key2"] $ object ["key1" .= "value1", "key2" .= "value2", "key3" .= "value3"]
Object (fromList [("key2",String "value2"),("key1",String "value1")])
>>> pick ["key3.key4"] $ object ["key1" .= "value1", "key2" .= "value2", "key3" .= object ["key4" .= "value4"]]
Object (fromList [("key3",Object (fromList [("key4",String "value4")]))])