listing JSON first level keys name

15 views
Skip to first unread message

Dader Grund

unread,
Sep 5, 2016, 4:34:34 AM9/5/16
to Ansible Project
Hallo,

Example :
{
        "fw1": {
                "ipv4": {
                        "rtr": {
                              
                                "ip": "1.2.3.4",
                                "net": "1.2.3.4",
                            
                        }
                }
        },
        "fw2": {
                "ipv4": {
                        "rtr": {
                                "ip": "4.3.2.1",
                                "net": "4.3.2.1",
                               
                        }
                }
        }
}

I need to parse the first level keys of a json file. Using 'from_json).keys()' i get  a strange syntax -->  [u'fw1', u'fw2'].
How do the 'u' characters come from and how to get rid of them ? Is there any way to list the keys instead of getting them in an Array ?

Reply all
Reply to author
Forward
0 new messages