Python convert json to python object and visit attribute using comma
<p>As title, A json object or convert to a python object like:</p>

<pre><code>u = {
    "name": "john",
    "coat": {
        "color": "red",
        "sex": "man",
    },
    "groups": [
        {"name": "git"},
        {"name": "flask"}
    ]
}
</code></pre>

<p>I want visit as:</p>

<pre><code>u.name 
</code></pre>

<p>It's easy to do with inherit from dict, but </p>

<pre><code>u.groups.0.name 
</code></pre>

<p>We also set it as </p>

<pre><code>u.name = "flask"
u.groups.0.name = "svn"
</code></pre>

<p>Thanks</p>

<p>Python is not JavaScript. You need to refer to <code>u["groups"][0]["name"]</code>.</p>

python