summaryrefslogtreecommitdiff
path: root/README.markdown
diff options
context:
space:
mode:
authorDmitry Ilyin <dilyin@mirantis.com>2016-04-26 21:51:43 +0300
committerDmitry Ilyin <dilyin@mirantis.com>2016-04-26 21:58:29 +0300
commit870a272cee6889934d60c4bfd7a814bcf47011f1 (patch)
tree4450edb42afb65d84ffe57a440747f56d4dbbfda /README.markdown
parentb63849c7865e4191e9df5a7651c16c072facee3d (diff)
Add the default value to the "loadyaml" function
This value will be returned if the is no file to load or a file could not be parsed. It's similar to the "parseyaml" function's default value. Add the "loadjson" function too
Diffstat (limited to 'README.markdown')
-rw-r--r--README.markdown32
1 files changed, 31 insertions, 1 deletions
diff --git a/README.markdown b/README.markdown
index 6cedc2a..eff3b28 100644
--- a/README.markdown
+++ b/README.markdown
@@ -660,12 +660,42 @@ Returns the keys of a hash as an array. *Type*: rvalue.
#### `loadyaml`
-Loads a YAML file containing an array, string, or hash, and returns the data in the corresponding native data type. For example:
+Loads a YAML file containing an array, string, or hash, and returns the data in the corresponding native data type.
+
+For example:
~~~
$myhash = loadyaml('/etc/puppet/data/myhash.yaml')
~~~
+The second parameter will be returned if the file was not found or could not be parsed.
+
+For example:
+
+ ~~~
+ $myhash = loadyaml('no-file.yaml', {'default'=>'value'})
+ ~~~
+
+*Type*: rvalue.
+
+#### `loadjson`
+
+Loads a JSON file containing an array, string, or hash, and returns the data in the corresponding native data type.
+
+For example:
+
+ ~~~
+ $myhash = loadjson('/etc/puppet/data/myhash.json')
+ ~~~
+
+The second parameter will be returned if the file was not found or could not be parsed.
+
+For example:
+
+ ~~~
+ $myhash = loadjson('no-file.json', {'default'=>'value'})
+ ~~~
+
*Type*: rvalue.
#### `load_module_metadata`