A simple library for filtering JSON using the fields syntax inspired by Google's Partial Response. Field masks remove unnecessary values while retaining the structure of the JSON resource.
a,b,ccomma-separated list will select multiple fieldsa/b/cpath will select a field from its parenta(b,c)sub-selection will select many fields from a parenta/*/cthe star*wildcard will select all items in a field
Terminal characters ,*()/ can be escaped using a single backslash \.
import qualified Data.Aeson as Aeson
import qualified Data.Aeson.QQ.Simple as Aeson
import qualified Data.ByteString.Lazy as BSL
import JSONMask (masked)
val :: Aeson.Value
val = [Aeson.aesonQQ|{"p":{"a":1,"b":2},"z":1}|]
main :: IO ()
main = BSL.putStr . Aeson.encode $ masked val "p/a,z"
-- {p: {a: 1}, z: 1}More examples can be found in the tests.