Python - Parsing Json format input
<p>I need to make a data parsing that come from another program in JSON format:</p>

<pre><code>import json

input = '''
Array
(
    [error] =&gt; Array
        (
        )
    [result] =&gt; Array
        (
            [0] =&gt; Person Object
                (
                    [arr:Person:private] =&gt; Array
                        (
                            [cf] =&gt; DRGMRO75P03G273O
                            [first_name] =&gt; Mario
                            [last_name] =&gt; Dragoni
                            [email] =&gt; mario.dragoni@yahoo.com
                            [phone] =&gt; 558723
                            [uid] =&gt; dragom
                            [source] =&gt; USRDATA
                        ) 
                )
            )
        )
'''
</code></pre>

<p>I tried:</p>

<pre><code>data = json.loads(input)
</code></pre>

<p>But I get:</p>

<pre><code>**ValueError:** No JSON object could be decoded
</code></pre>

<p>Perhaps the fault is due to lack of field separators?</p>

<p>Edit:</p>

<p>The input was generated by a <em>php</em> <strong>print_r</strong>, I replaced it with <strong>json_encode</strong></p>

<p>your function is correct.</p>

<p>but the provided json string is wrong</p>

<p>in fact the input is a mixed array and class object</p>

<p>you can import json in python like this:</p>

<pre><code>import json
j = json.loads('{"one" : "1", "two" : "2", "three" : "3"}')
print j['two']
</code></pre>

python json parsing