Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {-# LANGUAGE OverloadedStrings #-}
- module Test06 where
- import Prelude hiding (readFile, lookup)
- import Control.Monad.IO.Class
- import Control.Lens
- import Data.Aeson
- import Data.Aeson.Lens
- import qualified Data.ByteString as B
- main :: IO ()
- main = do
- val <- B.readFile "test/Data/test01.json"
- print val
- print $ val ^? key "lng" . nonNull
- print $ val ^? key "lng" . _String
- print $ val ^? key "resources" . _Object
- print $ val ^? key "resources" . key "en" . key "translation" . _Object
- print $ val ^? key "resources" . key "en" . key "translation" . key "look" . key "deep" . _Value
- print $ val ^? (foldl (.) _Value $ map key ["resources" , "en", "translation"])
- {-
- test/Data/test01.json
- {
- "lng": "en",
- "debug": true,
- "resources": {
- "en": {
- "translation" : {
- "key": "value of key",
- "look": {
- "deep": "value of look deep"
- }
- }
- }
- }
- }
- -}
Add Comment
Please, Sign In to add comment