When you try to set a value for a parameter in the console using a JSON hash, it is saved as a string. When you run Puppet, you get an expects a hash value, got string
error.
Version and installation information
PE version: All supported
Solution
You can structure parameters as JSON, but if they can’t be parsed as JSON, they’re treated as strings. JSON syntax requires that you use double quotes around the key in a key-value pair. The most common syntax issue that causes this error is using single quotes around the key in a key-value pair that makes up the parameter.
For example, the syntax for a basic JSON hash is: {"a": 1}
, where a
is the key and 1
is the value.
If you’re using a nested hash, make sure that your brackets are closed. For example:
{
"foo": {
"mount": "/-",
"mapfile": "/etc/auto.foo",
"options": "--timeout=120"
}
}
If you continue to have issues after checking for single quotes and open brackets, check that your parameter uses valid JSON using a JSON prettifier.
Note: The linked JSON prettifier is a third-party solution, and we’re not able to support it.
-
See more JSON examples in our Configuration file syntax documentation
How can we improve this article?
0 comments
Please sign in to leave a comment.
Related articles