Migrate CheckMK Plugin from 1.x to 2.x, whats equal to parse_json

If your agent output valid JSON then no such function is needed.
All my special agents use pure JSON output and a “json.loads(section[0][0])” is enough.

A simple parse function for JSON section could look like this.

def parse_redfish(string_table: StringTable) -> RedfishAPIData:
    """parse one line of data to dictionary"""
    try:
        return json.loads(string_table[0][0])
    except (IndexError, json.decoder.JSONDecodeError):
        return {}

The RedfishAPIData can be ignored.
For multiline JSON every line need to be a valid JSON structure and the parse function need to respect this.

1 Like