couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bram <>
Subject JSON serialization in views
Date Wed, 20 Jan 2010 12:57:10 GMT
Hi all,

I'm new to CouchDB and I ran into a small hick-up. I would like to hear
any opinions about my approach and any possible solutions I do not
mention myself ;)

Introduction: I decided to write a script to push /proc information into
a CouchDB instance and then use the map reduce to create graph data,
mean loads, etc. (Code is GPLv3, available at [1])

Approach: I have a json object within my entries to document where the
information came from (called acquire) and I would like to use a
concatenation of that information as a key in the emit() call. I decided
to try out: emit(doc.acquire, doc)

I like using doc.acquire directly because I don't have to concatenate
all the different fields by hand and it keeps it all readable and very

Problem: using a json object as a key value in emit will serialize it,
but the serialization does not seem to be stable, so serializing the
object {a:2,b:3} and {b:3, a:2} will not result in the same string.

Question: Is there a json serialization function/call that I can use to
sort on object attribute names, to make sure that {a:2,b:3} and {b:3,
a:2} will serialize to the same string?

  Bram Neijt


View raw message