[Python] Parse specific key from JSON, and extract if field matches

Discussão em 'Python' iniciado por Stack, Maio 23, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to parse this JSON file with the following declaration:

    {
    "results": [
    {
    "vulnerabilities": [
    {
    "status": "fixed in 1.3.1",
    "severity": "critical",
    },
    {
    "severity": "critical",
    },
    ],
    }
    ],
    }


    I have the following code:

    import json


    f = open('file.json',)
    json_object = json.load(f)

    for i in json_object['results']:
    print(i)

    f.close()


    this prints the whole declaration beginning at results: 0:

    How can I get it to print all vulnerabilities that have matching severity critical or high?

    Continue reading...

Compartilhe esta Página