Python - Filter a dict JSON response to send back only two values or convert to a string?
<p>I am manipulating a URL in Python that calls an API and gets a valid result in JSON.</p>

<p>I only need the 'latitude' and 'longitude' provided by [result]</p>

<p>But, I cannot seem to find any good way to handle sending dict values back.</p>

<p>I've tried to convert the JSON to a string, but as my end goal is to append the latitude and longitude to another URL, this seems silly?</p>

<p>Have been searching around, and seems parsing DICT a common issue.</p>

<p>Can anyone point me in the right direction?</p>

<p>My code (that ran)</p>

<pre><code>import urllib2
import json
Postcode = raw_input("Hello hello hello, what's your postcode..?  ")
PostcodeURL = 'https://api.postcodes.io/postcodes/' + Postcode
json_str = urllib2.urlopen(PostcodeURL).read()
d = json.loads(json_str)
print(d)
</code></pre>

<p>The output looks like this:</p>

<pre><code>{u'status': 200, u'result': {u'eastings': 531025, u'outcode': u'N8', u'admin_county': None, u'postcode'
</code></pre>

<p>You got a nested dictionary back, so access it's values using the right keys:</p>

<pre><code>d = json.loads(json_str)
lat, long = d['result']['latitude'], d['result']['longitude']
newurl = url + '?' + 'lat=' + lat + '&amp;lon=' + lon
</code></pre>

python json string dictionary filter