Skip to end of metadata
Go to start of metadata

LoxBerry 1.4

This shell tool is included in LoxBerry starting with LoxBerry V1.4. If you use that function, set this minimum version in your plugin.cfg.

LoxBerry ships with the tool jq, that can read and edit json files, as well as find values. The tools website is here, and more useful examples are listed here.

Simple examples

Sample json for the following examples

  "SMTP": {
    "ACTIVATE_MAIL": "1",
    "CRYPT": 1,
    "EMAIL": "",
    "PORT": "587",
    "SMTPPASS": "Eins, zwei, Polizei",
    "SMTPSERVER": ""

Take note that NOTIFICATION is an array, and SMTP is an object with elements.

Return the value of a key

$ jq '.SMTP.EMAIL' test.json

$ jq -r '.SMTP.EMAIL' test.json

$ jq '.NOTIFICATION' test.json

Test if an array element exists

$ jq '.NOTIFICATION | contains(["MAIL_SYSTEM_INFOS"])' test.json
$ jq '.NOTIFICATION | contains(["nonsense"])' test.json

Change a value

This is setting "ACTIVATE_MAIL": to "0".

# jq '.SMTP.ACTIVATE_MAIL = "0"' test.json > testnew.json

Take special care that you cannot directly replace the original file, as the jq parser operates line by line. Therefore you need to create a new file, and then move it over the old one.

  • No labels