Skip to content

cli,output: print valid json for network scan result

Based on the discussion in the mailinglist: @aleksm

A network scan with json output currently returns the following:

root@G3-10940 ~ # mmcli -m 0 -J --3gpp-scan --timeout=300 | jq
{
  "modem": {
    "3gpp": {
      "scan-networks": [
        "operator-code: 26201, operator-name: TDG, access-technologies: lte, availability: forbidden",
        "operator-code: 26203, operator-name: o2 - de, access-technologies: lte, availability: forbidden",
        "operator-code: 26202, operator-name: vodafone.de, access-technologies: lte, availability: current"
      ]
    }
  }
}

This is a valid JSON, but in order to be able to access the individual data elements more easily, the line can also be dumped as a json object.

The following commit converts the lines into a JSON obejct, so that it looks like this:

root@G3-10940 ~ # mmcli -m 0 -J --3gpp-scan --timeout=300 | jq
{
  "modem": {
    "3gpp": {
      "scan-networks": [
        {
          "operator-code": "26201",
          "operator-name": "TDG",
          "access-technologies": "lte",
          "availability": "forbidden"
        },
        {
          "operator-code": "26203",
          "operator-name": "o2 - de",
          "access-technologies": "lte",
          "availability": "forbidden"
        },
        {
          "operator-code": "26202",
          "operator-name": "vodafone.de",
          "access-technologies": "lte",
          "availability": "current"
        }
      ]
    }
  }
}
Edited by Florian Eckert

Merge request reports

Loading