Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem to parse a json
#1
Hi

I've some problem to parse my json
which is like:

{
    "Results": {
        "check1": {
            "LastResultTime": 1607002708,
            "LastResultTimeH": "2020-12-03 14:38:28 +0100 CET",
            "Status": 0,
            "StatusH": "OK",
            "Origin": "1"
        },
        "check2": {
            "LastResultTime": 1607002934,
            "LastResultTimeH": "2020-12-03 14:42:14 +0100 CET",
            "Status": 0,
            "StatusH": "KO",
            "Origin": "1"
        },
        "check3": {
            "LastResultTime": 1607002934,
            "LastResultTimeH": "2020-12-03 14:42:14 +0100 CET",
            "Status": 2,
            "StatusH": "CRITICAL",
            "Origin": "2"
        }
    },
    "Status": 2,
    "StatusH": "CRITICAL",
    "Maintenance": {
        "Reason": "Ok",
        "Status": 0,
        "StatusH": "STATE_OK",
        "When": "2020-12-03 14:42:14.377955151 +0100 CET m=+0.000776843"
    },
}
I want to parse this json with python and retrieve values like:
Check1 / StatusH / OK
Check2 / StatusH / KO
check3 / StatusH / CRITICAL
etc...
I'm trying with
data = json.loads(json_data.decode(), parse_float=float)
for i in data['Results']:
    for a, b in data.items():
        if (a == "StatusH"):
            print (i,b)
But it doesnt work:
check1 CRITICAL
check2 CRITICAL
check3 CRITICAL
If someone has an idea..
Thanks for any help

Alex
Reply


Messages In This Thread
Problem to parse a json - by enigma619 - Dec-03-2020, 04:12 PM
RE: Problem to parse a json - by enigma619 - Dec-03-2020, 04:26 PM
RE: Problem to parse a json - by Larz60+ - Dec-03-2020, 04:32 PM
RE: Problem to parse a json - by enigma619 - Dec-04-2020, 08:16 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  parse json field from csv file lebossejames 4 793 Nov-14-2023, 11:34 PM
Last Post: snippsat
  [split] Parse Nested JSON String in Python mmm07 4 1,583 Mar-28-2023, 06:07 PM
Last Post: snippsat
  Trying to parse only 3 key values from json file cubangt 8 3,546 Jul-16-2022, 02:05 PM
Last Post: deanhystad
  Problem with nested JSON Kalet 7 2,831 Dec-09-2021, 11:13 PM
Last Post: Gribouillis
  Problem with Json Array kwekey 2 1,700 Aug-02-2021, 05:11 PM
Last Post: kwekey
  How to parse JSON DIC? ogautier 4 2,276 Sep-15-2020, 06:03 PM
Last Post: ogautier
  Parse JSON multiple objects larkin_L 8 5,836 May-27-2020, 11:18 AM
Last Post: nuffink
  How can i parse a log file to JSON. menarcarlos 2 2,457 May-26-2020, 10:23 AM
Last Post: buran
  json problem enigma619 9 3,757 Dec-19-2019, 08:29 AM
Last Post: enigma619
  Output to a json file problem Netcode 3 3,771 Nov-22-2019, 01:44 AM
Last Post: Skaperen

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020