37bb654424
Change-Id: Id124ec4c598c7b6bcb7c8134d75825fd01d938d2
17 lines
370 B
Ruby
17 lines
370 B
Ruby
Puppet::Functions.create_function(:convert_to_json_string) do
|
|
def convert_to_json_string(*args)
|
|
require 'json'
|
|
value = args[0]
|
|
if (value.kind_of? Array) && value.all? {|x| x.include? ":"}
|
|
h = {}
|
|
value.each do |s|
|
|
k,v = s.split(/:/)
|
|
h[k] = v
|
|
end
|
|
return h.to_json
|
|
else
|
|
return value.to_json
|
|
end
|
|
end
|
|
end
|