3 def array_of_hash?(list)
4 return false unless !list.empty? && list.class == Array
6 return false unless e.class == Hash
11 module Puppet::Parser::Functions
12 newfunction(:check_array_of_hash, :arity =>1, :type => :rvalue, :doc => "Check
13 input String is a valid Array of Hash in JSON style") do |arg|
14 if arg[0].class == String
16 list = JSON.load(arg[0].gsub("'","\""))
17 rescue JSON::ParserError
18 raise Puppet::ParseError, "Syntax error: #{arg[0]} is invalid"
20 return arg[0] if array_of_hash?(list)
23 raise Puppet::ParseError, "Syntax error: #{arg[0]} is not a String"