python - How to sum integers stored in json -


how can sum count values? json data following.

{   "note":"this file contains sample data testing",   "comments":[     {       "name":"romina",       "count":97     },     {       "name":"laurie",       "count":97     },     {       "name":"bayli",       "count":90     }   ] } 

this how did eventually.

import urllib import json mysumcnt = 0 input = urllib.urlopen('url').read()  info = json.loads(input) myinfo = info['comments']  item in myinfo:     mycnt = item['count']     mysumcnt += mycnt print mysumcnt 

Comments