Method: Puppet::ModuleTool::Metadata#to_json

Defined in:
lib/puppet/module_tool/metadata.rb

#to_jsonObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/puppet/module_tool/metadata.rb', line 101

def to_json
  data = @data.dup.merge('dependencies' => dependencies)

  contents = data.keys.map do |k|
    value = begin
      Puppet::Util::Json.dump(data[k], :pretty => true)
    rescue
      data[k].to_json
    end
    %Q("#{k}": #{value})
  end

  "{\n" + contents.join(",\n").gsub(/^/, '  ') + "\n}\n"
end