hjsonpointer

JSON Pointer library https://github.com/seagreen/hjsonpointer

Version on this page:1.2.0
LTS Haskell 9.18:1.2.0
Stackage Nightly 2017-12-13:1.3.0
Latest on Hackage:1.3.0
MIT licensed by Ian Grant Jeffries
Maintained by ian@housejeffries.com

Module documentation for 1.2.0

Summary

JSON Pointer library for Haskell.

Hackage / GitHub / Travis CI

Example

module Example where

import           Control.Monad (unless)
import           Data.Aeson
import qualified JSONPointer   as JP

main :: IO ()
main = do
    -- JSON Pointers must either be empty or start with a /.
    pntr1 <- case JP.unescape "/foo/0" of
                 Left _     -> error "Failed to construct JSON Pointer."
                 Right pntr -> return pntr

    -- We can also write JSON Pointers in Haskell.
    let pntr2 = JP.Pointer [JP.Token "/"]
    -- When we do this we don't have to escape / or ~ characters
    -- (as ~1 and ~0 respectively) like we do in an escaped JSON
    -- Pointer string.
    unless (JP.unescape "/~1" == Right pntr2) (error "ohno!")

    print (JP.resolve pntr1 document)
    print (JP.resolve pntr2 document)

  where
    document :: Value
    document = object [ "foo" .= [String "bar", String "baz"]
                      , "/"   .= String "quux"
                      ]

Output:

Right (String "bar")
Right (String "quux")

Changes

1.3.0

  • Test with GHC 8.2. Drop GHC 7.8.

1.2.0

  • Track upper bounds in a Hackage revision instead of source code.

1.1.1

  • Bump aeson.

1.1.0.2

  • Raise test dep upper bounds.

1.1.0.1

  • Bump vector.

1.1.0.0

  • Rename the module to JSONPointer.
  • Bump aeson.
  • Derive Semigroup for Pointer.
  • Reorganize code.

1.0.0.2

  • Bump hspec.

1.0.0.1

  • Remove HUnit dep.

1.0.0.0

  • Bump aeson.

0.3.0.2

  • Switch to hspec for tests.

0.3.0.1

  • Enable GHC 8.

0.3.0.0

  • Rewrite.

0.2

  • Fix mistake in resolveRefTok.
  • Split errors over two types.
  • Switch the order of pointer and value arguments for functions that take both. The pointer now comes first.

0.1

  • Initial implementation.
Used by 1 package:
comments powered byDisqus