-# Take a data structure and output it as pretty JSON
+require 'json'
+# @summary
+# Convert data structure and output to pretty JSON
#
-# @example how to output pretty JSON
-# # output pretty json to a file
+# @example **Usage**
+# * how to output pretty JSON to file
# file { '/tmp/my.json':
# ensure => file,
# content => to_json_pretty($myhash),
# }
#
-# @example how to output pretty JSON skipping over keys with undef values
-# # output pretty JSON to a file skipping over undef values
+# * how to output pretty JSON skipping over keys with undef values
# file { '/tmp/my.json':
# ensure => file,
# content => to_json_pretty({
# param_two => undef,
# }),
# }
-#
-require 'json'
-
Puppet::Functions.create_function(:to_json_pretty) do
+ # @param data
+ # data structure which needs to be converted to pretty json
+ # @param skip_undef
+ # value `true` or `false`
+ # @return
+ # converted data to pretty json
dispatch :to_json_pretty do
param 'Variant[Hash, Array]', :data
optional_param 'Boolean', :skip_undef