module Hedgehog.Extras.Stock.Aeson
( rewriteObject
, rewriteArrayElements
) where
import Data.Aeson
import Data.Aeson.KeyMap (KeyMap)
import Data.Functor
rewriteObject :: (KeyMap Value -> KeyMap Value) -> Value -> Value
rewriteObject :: (KeyMap Value -> KeyMap Value) -> Value -> Value
rewriteObject KeyMap Value -> KeyMap Value
f (Object KeyMap Value
hm) = KeyMap Value -> Value
Object (KeyMap Value -> KeyMap Value
f KeyMap Value
hm)
rewriteObject KeyMap Value -> KeyMap Value
_ Value
v = Value
v
rewriteArrayElements :: (Value -> Value) -> Value -> Value
rewriteArrayElements :: (Value -> Value) -> Value -> Value
rewriteArrayElements Value -> Value
f (Array Array
hm) = Array -> Value
Array ((Value -> Value) -> Array -> Array
forall a b. (a -> b) -> Vector a -> Vector b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Value -> Value
f Array
hm)
rewriteArrayElements Value -> Value
_ Value
v = Value
v