Puppet Function: parsepson
- Defined in:
- lib/puppet/functions/parsepson.rb
- Function type:
- Ruby 4.x API
Summary
**Deprecated:** Starting Puppet 8, we no longer natively support PSON usage. This function should be removed once we stop supporting Puppet 7. 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
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/puppet/functions/parsepson.rb', line 15 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) call_function('deprecation', 'parsepson', 'This method is deprecated. From Puppet 8, PSON is no longer natively supported. Please use JSON.parse().') PSON.load(pson_string) if Puppet::Util::Package.versioncmp(Puppet.version, '8').negative? rescue StandardError => e Puppet.debug("Parsing PSON failed with error: #{e.}") raise e if default == :no_default_provided default end end |