module Puppet::Pops::Serialization::JsonPath

Public Class Methods

to_json_path(path) click to toggle source

Creates a json_path reference from the given `path` argument

@path path [Array<Integer,String>] An array of integers and strings @return [String] the created json_path

@api private

   # File lib/puppet/pops/serialization/json_path.rb
13 def self.to_json_path(path)
14   p = String.new('$')
15   path.each do |seg|
16     if seg.nil?
17       p << '[null]'
18     elsif Types::PScalarDataType::DEFAULT.instance?(seg)
19       p << '[' << Types::StringConverter.singleton.convert(seg, '%p') << ']'
20     else
21       # Unable to construct json path from complex segments
22       return nil
23     end
24   end
25   p
26 end