Reputation: 4704
I am a getting query result from couchdb emit
function in python as follows:
<Row id=u'c0cc622ca2d877432a5ccd8cbc002432', key=u'eric', value={u'_rev': u'1-e327a4c2708d4015e6e89efada38348f', u'_id': u'c0cc622ca2d877432a5ccd8cbc002432', u'email': u'yap', u'name': u'eric'}>
How do I parse the content of value item as:
{u'_rev': u'1-e327a4c2708d4015e6e89efada38348f', u'_id': u'c0cc622ca2d877432a5ccd8cbc002432', u'email': u'yap', u'name': u'eric'}
using json?
Upvotes: 1
Views: 400
Reputation: 2818
The value is already converted to a python dictionary. So, if you need to change it to a JSON string just use json.loads, otherwise you can access the key with row.key and value attributes with row.value['some_attribute'].
Upvotes: 0
Reputation: 1102
I'm not sure what you mean by "parsing the contents using json". The data should already be parsed and you can refer to any attributes by doing something like row.value["_id"]
where row
is the name of the variable referencing the Row
object.
Upvotes: 1