python - JSON Object parsing: Loop through dynamic data -


i have json object follows:

{u'2015-05-11': 2, u'2015-05-04': 1} 

here dates can vary, i.e., can query multiple dates.

i want extract numbers in object , add them. in example want extract 2 , 1 , them result 3.

another example:

{u'2015-05-11': 6, u'2015-05-04': 0} 

here answer 6 + 0 = 6.

another example of json object multiple dates:

{u'2015-04-27': 0, u'2015-05-11': 2, u'2015-05-04': 1} 

here answer be: 0 + 2 + 1 = 3

i want loop through json object , extract numbers. i've read answers provided here , here. problem the, json object have not have fixed key can query.

how go this?

these python dicts, not json objects.

since don't seem care keys @ all, can values , sum them:

result = sum(data.values()) 

Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -