Module: Puppet::Pops::Serialization::JsonPath

Defined in:
lib/puppet/pops/serialization/json_path.rb

Defined Under Namespace

Classes: Resolver

Class Method Summary collapse

Class Method Details

.to_json_path(path) ⇒ String

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Creates a json_path reference from the given `path` argument


10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/puppet/pops/serialization/json_path.rb', line 10

def self.to_json_path(path)
  p = '$'
  path.each do |seg|
    if seg.nil?
      p << '[null]'
    elsif Types::PScalarDataType::DEFAULT.instance?(seg)
      p << '[' << Types::StringConverter.singleton.convert(seg, '%p') << ']'
    else
      # Unable to construct json path from complex segments
      return nil
    end
  end
  p
end