How to generate unique name for each JSON value
<p>I have following JSON, returned from a REST service, where I want to generate a unique names for each value by combining parent keys. For example. <code>name+phone+address+city+name</code> , <code>name+phone+address+city+population+skilled+male</code> and so on. </p>

<pre><code>{
  "name": "name",
  "phone": "343444444",
  "address": {
    "lat": 23.444,
    "lng": 34.3322,
    "city":{
      "name": "city name",
      "population": {
        "skilled": {
          "male": 2,
          "female": 4
        },
        "uneducated": {
          "male": 20,
          "femail": 4
        }
      }
    }
  },
  "email": "email",
  "education": "phd"
}
</code></pre>

<p>I want to combine all key names starting from the parent of the JSON tree.</p>

<p>Here is what I am doing</p>

<pre><code>class TestJson
     def walk_through(self, json_object):
        for k, v in json_object.items():
            self.x_path = self.x_path + k
            if type(v) is dict:
                self.walk_through(v)
            else:
                print(self.x_path)
                self.x_path = ""
</code></pre>

<p>This code is printing keys but only starting from the current parent node. I want to combine all keys up to root of the json. </p>

<p>If you want to print all keys of your python dict you can do the following:</p>

<pre><code>def print_keys(d):
    for key, value in d.iteritems():
        print key,
        if isinstance(value, dict):
            print_keys(value)
</code></pre>

python json python-3.x