src/jsonpak/jsonptr

Source   Edit  

Types

JsonPtr = distinct string
Source   Edit  
JsonPtrError = object of CatchableError
Source   Edit  
PathError = object of JsonPtrError
Source   Edit  
PathResult = object
  node*: NodePos
  parents*: seq[PatchPos]
  key*: string
Source   Edit  
SyntaxError = object of JsonPtrError
Source   Edit  
UsageError = object of JsonPtrError
Source   Edit  

Procs

func addEscapedJsonPtr(result: var string; s: string) {....raises: [], tags: [],
    forbids: [].}
The same as result.add(escapeJsonPtr(s)), but more efficient. Source   Edit  
func escapeJsonPtr(s: string): string {....raises: [], tags: [], forbids: [].}

Escaped s for inclusion into a JSON Pointer.

'~' => ~0 '/' => ~1

You can also use addEscapedJsonPtr proc.

Source   Edit  
proc findNode(tree: JsonTree; path: string): NodePos {.
    ...raises: [UsageError, SyntaxError], tags: [], forbids: [].}
Source   Edit  
proc findNodeMut(tree: JsonTree; path: string): PathResult {.
    ...raises: [UsageError, SyntaxError, PathError], tags: [], forbids: [].}
Source   Edit  
proc raisePathError(path: string) {.noinline, ...raises: [PathError], tags: [],
                                    forbids: [].}
Source   Edit  
proc raiseSyntaxError(token: string) {.noinline, ...raises: [SyntaxError],
                                       tags: [], forbids: [].}
Source   Edit  
proc raiseUsageError(token: string) {.noinline, ...raises: [UsageError], tags: [],
                                      forbids: [].}
Source   Edit  
func unescapeJsonPtr(token: var string) {....raises: [UsageError, SyntaxError],
    tags: [], forbids: [].}

Unescapes a string s.

This complements escapeJsonPtr func as it performs the opposite operations.

Source   Edit