Puppet Function: parsepson
- Defined in:
- vendor_modules/stdlib/lib/puppet/functions/parsepson.rb
- Function type:
- Ruby 4.x API
Summary
This function accepts PSON, a Puppet variant of JSON, as a string and converts it into the correct Puppet structureOverview
For more information on PSON please see the following link: puppet.com/docs/puppet/7/http_api/pson.html
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'vendor_modules/stdlib/lib/puppet/functions/parsepson.rb', line 13 Puppet::Functions.create_function(:parsepson) do # @param pson_string A valid PSON string # @param default An optional default to return if parsing the pson_string fails # @return [Data] dispatch :parsepson do param 'String[1]', :pson_string optional_param 'Any', :default end def parsepson(pson_string, default = :no_default_provided) PSON.load(pson_string) rescue StandardError => err Puppet.debug("Parsing PSON failed with error: #{err.}") raise err if default == :no_default_provided default end end |