Safe Haskell | None |
---|---|
Language | Haskell2010 |
- newtype Pointer = Pointer {
- _unPointer :: [Token]
- newtype Token = Token {}
- escape :: Pointer -> Text
- data FormatError
- unescape :: Text -> Either FormatError Pointer
- unescapeToken :: Text -> Maybe Token
- data ResolutionError
- resolve :: Pointer -> Value -> Either ResolutionError Value
- resolveToken :: Token -> Value -> Either ResolutionError Value
Documentation
Pointer | |
|
We don't try to distinguish between integer tokens and string tokens since all tokens start as strings, and all tokens can be used to resolve JSON objects.
Unescaping
data FormatError Source #
InvalidFirstChar | JSON Pointers must either be empty or start with a |
UnescapedTilde |
unescape :: Text -> Either FormatError Pointer Source #
JSON Pointers must either be empty or start with a /
. This means
that if you're turning a URI Fragment into a JSON Pointer you must
drop the initial #
.
Note that the unescaping happening here is not the same as URI
decoding. If you are turning a URI fragment into a JSON Pointer you
must URI decode the Text
before using it as an argument to this
function. There's an example of how to do this in the tests using
"Network.HTTP.Types.URI.urlDecode" from http-types.
Resolution
data ResolutionError Source #
resolveToken :: Token -> Value -> Either ResolutionError Value Source #
For internal use (or specialized applications that don't want to resolve an entire pointer at once).