Prototype: readjson(filename, optional_maxbytes)

Return type: data

Description: Parses JSON data from the file filename and returns the result as a data variable. maxbytes is optional, if specified, only the first maxbytes bytes are read from filename.

Arguments:

  • filename: string - File name - in the range: "?(/.*)
  • optional_maxbytes: int - Maximum number of bytes to read - in the range: 0,99999999999

Example:

code
vars:

  "loadthis"

     data =>  readjson("/tmp/data.json", 4000);

See also: data_expand(), readdata(), parsejson(), storejson(), parseyaml(), readyaml(), mergedata(), validjson(), and data documentation.

History:

  • Introduced in CFEngine 3.6.0