Javascript JPath

From Yate Documentation
(Difference between revisions)
Jump to: navigation, search
(Created page with "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 ...")
 
 
Line 37: Line 37:
 
Return:<br>
 
Return:<br>
 
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.
 
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.
 +
 +
 +
[[Category:Javascript]]

Latest revision as of 12:39, 9 September 2024

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

[edit] Constructor

  • new JPath(str)

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

[edit] 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