]> git.donarmstrong.com Git - dsa-puppet.git/blob - modules/stdlib/lib/puppet/parser/functions/parsejson.rb
upgrade to concat 2.0.0
[dsa-puppet.git] / modules / stdlib / lib / puppet / parser / functions / parsejson.rb
1 #
2 # parsejson.rb
3 #
4
5 module Puppet::Parser::Functions
6   newfunction(:parsejson, :type => :rvalue, :doc => <<-EOS
7 This function accepts JSON as a string and converts into the correct Puppet
8 structure.
9     EOS
10   ) do |arguments|
11
12     if (arguments.size != 1) then
13       raise(Puppet::ParseError, "parsejson(): Wrong number of arguments "+
14         "given #{arguments.size} for 1")
15     end
16
17     json = arguments[0]
18
19     # PSON is natively available in puppet
20     PSON.load(json)
21   end
22 end
23
24 # vim: set ts=2 sw=2 et :