hjsonpointer: JSON Pointer library

[ data, deprecated, library, mit ] [ Propose Tags ]
Deprecated

Modules

[Index]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0, 0.1.0.1, 0.2.0.0, 0.2.0.1, 0.2.0.2, 0.2.0.3, 0.2.0.4, 0.3.0.0, 0.3.0.1, 0.3.0.2, 1.0.0.0, 1.0.0.1, 1.0.0.2, 1.1.0.0, 1.1.0.1, 1.1.0.2, 1.1.1, 1.2.0, 1.3.0, 1.4.0, 1.5.0
Change log changelog.md
Dependencies aeson (>=0.7 && <1.1), base (>=4.6 && <4.10), QuickCheck (>=2.8 && <2.10), text (>=1.2 && <1.3), unordered-containers (>=0.2 && <0.3), vector (>=0.10 && <0.12) [details]
License MIT
Author Ian Grant Jeffries
Maintainer ian@housejeffries.com
Category Data
Home page https://github.com/seagreen/hjsonpointer
Source repo head: git clone git://github.com/seagreen/hjsonpointer.git
Uploaded by seagreen at 2016-10-20T18:09:19Z
Distributions
Reverse Dependencies 2 direct, 6 indirect [details]
Downloads 15982 total (47 in the last 30 days)
Rating 1.75 (votes: 1) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2016-10-20 [all 1 reports]

Readme for hjsonpointer-1.0.0.2

[back to package description]

Summary

JSON Pointer library for Haskell.

Hackage / GitHub / Travis CI

Example

{-# LANGUAGE OverloadedStrings #-}

module Example where

import           Control.Monad      (unless)
import           Data.Aeson
import qualified Data.Aeson.Pointer as P

main :: IO ()
main = do
    -- JSON Pointers must either be empty or start with a /.
    pntr1 <- case P.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 = P.Pointer [P.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 (P.unescape "/~1" == Right pntr2) (error "ohno!")

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

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

Output:

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