JSON

Although not commonly used as the primary backend for Hiera, JavaScript Object Notation (JSON) is also a backend option. JSON is generally not as readable as YAML. It is primarily meant to be easily parsed. An advantage of JSON is that it is widely used by web applications and can be easily generated. The JSON syntax can be verified using Node.js and the JSON.parse JavaScript function.

Consider the following JSON code, which is stored in the example.json file:

{ "books" : [
{ "title":"Mastering Puppet" , "pages":"300" },
{ "title":"Puppet Cookbook" , "pages":"250" },
{ "title":"Troubleshooting Puppet" , "pages":"100" } 
  ]
}

We can parse the file with Node.js by using the JSON.parse function. Install the Node.js binary.

Tip

Node.js is available ...

Get Troubleshooting Puppet now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.