X-Git-Url: https://git.adam-barratt.org.uk/?p=mirror%2Fdsa-puppet.git;a=blobdiff_plain;f=3rdparty%2Fmodules%2Fstdlib%2Flib%2Fpuppet%2Fparser%2Ffunctions%2Floadjson.rb;h=3c6087855adcae47f57887492560c6d8a58c7e5d;hp=f022bcdda36c07f9ef188e411f3f865954121bc5;hb=30caaa85aed7015ca0d77216bff175eebd917eb7;hpb=6f656bd4265e3dab13b9af2bf96e9044322e9d8f diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/loadjson.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/loadjson.rb index f022bcdda..3c6087855 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/loadjson.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/loadjson.rb @@ -4,18 +4,22 @@ module Puppet::Parser::Functions newfunction(:loadjson, :type => :rvalue, :arity => -2, :doc => <<-'DOC') do |args| - Load a JSON file containing an array, string, or hash, and return the data - in the corresponding native data type. + @summary + Load a JSON file containing an array, string, or hash, and return the data + in the corresponding native data type. + The first parameter can be a file path or a URL. The second parameter is the default value. It will be returned if the file was not found or could not be parsed. - For example: + @return [Array|String|Hash] + The data stored in the JSON file, the type depending on the type of data that was stored. - $myhash = loadjson('/etc/puppet/data/myhash.json') - $myhash = loadjson('https://example.local/my_hash.json') - $myhash = loadjson('https://username:password@example.local/my_hash.json') - $myhash = loadjson('no-file.json', {'default' => 'value'}) + @example Example Usage: + $myhash = loadjson('/etc/puppet/data/myhash.json') + $myhash = loadjson('https://example.local/my_hash.json') + $myhash = loadjson('https://username:password@example.local/my_hash.json') + $myhash = loadjson('no-file.json', {'default' => 'value'}) DOC raise ArgumentError, 'Wrong number of arguments. 1 or 2 arguments should be provided.' unless args.length >= 1