Python Forum
Need help Understanding JSON
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need help Understanding JSON
#1
Hello, I am not very good with python currently. I am trying to pull data from a json file. I have found seeral examples but nothing seems to work for me. The examples seem to work with the example file. When I try to use my file I get an error "list indices must be integers or slices, not dict". For example this works as expected https://pythonguides.com/json-data-in-python/. When I change the file name to load my file it throws that error. This is very frustrating. There are a lot of these sections. If anyone can point me to an article or can explain how to do what I want. Which is just extract all the urls out of the file. Thank you.

Los of these sections
"kind": "some text"
"Entries": [

This is a small example of the json file I am trying to manipulate:

[
    {
        "kind": "Symantec Endpoint Protection client/ Symantec Agent",
        "entries": [
            {
                "date": "2021-06-14",
                "url": "https://liveupdate.symantec.com",
                "description": "Agent Installation Package",
                "inbound": false,
                "outbound": true
            },
            {
                "date": "2021-06-14",
                "url": "https://liveupdate.symantecliveupdate.com",
                "description": "Agent Installation Package",
                "inbound": false,
                "outbound": true
            },
            {
                "date": "2021-06-14",
                "url": "https://ent-shasta-rrs.symantec.com",
                "description": "Symantec reputation servers",
                "inbound": false,
                "outbound": true
            },
             "outbound": true
            }
        ]
    },
    {
        "kind": "Additional Entries for Cloud Managed/ Hybrid managed Agents",
        "entries": [
            {
                "date": "2021-06-14",
                "url": "https://usea1.r3.securitycloud.symantec.com",
                "description": "Symantec Cloud API gateway",
                "inbound": false,
                "outbound": true
            },
            {
                "date": "2021-06-14",
                "url": "https://us.spoc.securitycloud.symantec.com",
                "description": "Cloud notification service (SPOC)",
                "inbound": false,
                "outbound": true
            },
            {
                "date": "2021-06-14",
                "url": "https://storage.googleapis.com",
                "description": "Cloud storage services, Live Shell",
                "inbound": false,
                "outbound": true
            },
            {
                "date": "2021-06-14",
                "url": "https://ws.securitycloud.symantec.com",
                "description": "Live Shell",
                "inbound": false,
                "outbound": true
            },
            {
                "date": "2021-06-14",
                "url": "https://bds.securitycloud.symantec.com",
                "description": "Live Shell",
                "inbound": false,
                "outbound": true
            }
        ]
    },
Gribouillis write Aug-15-2022, 02:35 PM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Reply


Messages In This Thread
Need help Understanding JSON - by quarinteen - Aug-15-2022, 01:29 PM
RE: Need help Understanding JSON - by deanhystad - Aug-15-2022, 02:48 PM
RE: Need help Understanding JSON - by quarinteen - Aug-15-2022, 04:27 PM
RE: Need help Understanding JSON - by deanhystad - Aug-15-2022, 08:33 PM

Forum Jump:

User Panel Messages

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