Method: Janeway.path_to_diggable

Defined in:
lib/janeway.rb

.path_to_diggable(jsonpath) ⇒ Array<String, Integer>

Transform a jsonpath singular query into an array of values suitable for providing to Hash#dig or Array#dig.

Only singular queries are allowed, meaning queries that contain only name selectors (ie. hash keys) and index selectors (array indexes.) The paths that are yielded to Enumerator#each are all suitable for this.

Examples:

convert normalized jsonpath to array of hash keys / array indices

Janeway.path_to_diggable('$["a"].b.c[0]') => ["a", "b", "c", 0]

Parameters:

  • jsonpath (String)

    jsonpath query

Returns:

  • (Array<String, Integer>)

Raises:

  • (NotImplementedError)


69
70
71
# File 'lib/janeway.rb', line 69

def self.path_to_diggable(jsonpath)
  raise NotImplementedError
end