Q:

how to limit appending json objects in python

I want to only add 10 objects to my json array when I append, but in this current method I end up appending all key/values that match. 
Is there a graceful way to limit only 10 objects being appended inside the for loop?
for i in jsonData['data']:
            response.append({'lat': i['lat'], 'long' : i['long']})
            json.dumps(response)

A:

If the data is a list, you can slice:
for i in jsonData['data'][:10]:
    response.append({'lat': i['lat'], 'long' : i['long']})
    json.dumps(response)

Otherwise, break at the count of 10:
for i, v in enumerate(jsonData['data']):
    if i == 10:
        break
    response.append({'lat': v['lat'], 'long' : v['long']})
    json.dumps(response)

