- Create a new project, working-with-aeson-lens, with a simple stack template.
stack new working-with-aeson-lens simple
- Add a dependency on the lens library in the build-depends sub-section of the executable section. Also add dependency on aeson and lens-aeson libraries. Also add bytestring and text, as aeson uses bytestring for parsing and text for string values. Add vector, as we need to work with arrays in JSON:
executable working-with-aeson-lens hs-source-dirs: src main-is: Main.hs default-language: Haskell2010 build-depends: base >= 4.7 && < 5 , lens , lens-aeson , aeson , bytestring , text , vector
- Open src/Main.hs. We will be adding our source here. Use the OverloadedStrings extension and define the Main module. ...