select dict object based on value
<p>This is how my JSON object looks like:</p>

<pre><code>[{
    'Description': 'Description 1',
    'OutputKey': 'OutputKey 1',
    'OutputValue': 'OutputValue 1'
},
{
    'Description': 'Description 2',
    'OutputKey': 'OutputKey 2',
    'OutputValue': 'OutputValue 2'
},
{
    'Description': 'Description 3',
    'OutputKey': 'OutputKey 3',
    'OutputValue': 'OutputValue 3'
},
{
    'Description': 'Description 4',
    'OutputKey': 'OutputKey 4',
    'OutputValue': 'OutputValue 4'
},
{
    'Description': 'Description 5',
    'OutputKey': 'OutputKey 5',
    'OutputValue': 'OutputValue 5'
},
{
    'Description': 'Description 6',
    'OutputKey': 'OutputKey 6',
    'OutputValue': 'OutputValue 6'
}]
</code></pre>

<p>How do i grab the dict object where OutputKey is 4 without looping thru?</p>

<p><code>any(key['OutputKey'] == 'OutputKey 4' for key in myJSON)</code> returns true but i need it to grab the whole JSON object that belongs to that key.</p>

<p>A JSON Object is essentially a list of dictionaries. Therefore you need to use index notation to access one of the dictionaries, in this case myJSON[3]. Then inside the dictionary, call that dictionary's key so that it will return its value. So:</p>

<p><code>myJSON[3]['OutputKey']</code></p>

<p>will return OutputKey4.</p>

python