Javascript JPath

From Yate Documentation
Revision as of 13:39, 9 September 2024 by Marian (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Javascript JPath as specified in RFC 6901.

Notes:

  • Path items separator is slash (/) character
  • Path may not start with slash (/) character
  • Escape char is tilde (~). The following characters MUST be escaped in path item names:
    • Tilde (~): ~0
    • Slash (/): ~1

Constructor

  • new JPath(str)

Create a new JPath object.
Parameters:
str: String with JSON path

Methods

  • valid()

Check if path is valid.
Return:
True if path is valid, false otherwise

  • getItems()

Retrieve path item(s).
Return:
Array of strings. Each item contains its unescaped value. Array may be empty for empty or invalid paths

  • count()

Retrieve the number of items in path.
Return:
Number of items in path, 0 if path is empty or invalid

  • at(idx)

Retrieve the path item at given index.
Parameters:
idx: 0 based index to retrieve
Return:
Path item string (unescaped, may be empty), 'undefined' if index is out of range. Index may be out of range for empty or invalid paths.

Personal tools
Namespaces

Variants
Actions
Preface
Configuration
Administrators
Developers