Greetings,

I am storing data in some ETS and DETS tables.  I want to be able to take either one, some or all of the objects stored in the table and encode it/them into a JSON object.

http://steve.vinoski.net/pdf/IC-Yaws.pdf has a simple example (top of page 92) on using json2:encode/1:

Json = json2:encode( { struct, [{"location", NewLoc}] } ),

I have a little bit more data, so I'm guessing we can extrapolate that to:

Json = json2:encode( { struct, [ {"key1","val1"} , {"key2","val2"} , {"key3","val3"} ] } )

But I don't know how to add the remaining objects to that structure in the case when I want to convert more objects from the table.

Basically, I want to be able to do something like this for a whole table:

EncoderFriendlyStructure = someFunction(ListOfFieldNames, ETStable).
Json = json2:encode(EncoderFriendlyStructure).

or this for a single object or subset of objects:

EncoderFriendlyStructure = someFunction(ListOfFieldNames, ETStable, PartialKeyList).
Json = json2:encode(EncoderFriendlyStructure).

From the number of JSON modules out there, I get the feeling that this problem has been solved multiple times over and don't really want to reinvent the wheel…  What's the YAWS/json2 way?

Cheers.