You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Dan Santner <da...@me.com> on 2013/12/12 14:45:27 UTC

Simplest path from couch to C?

Hey guys I know this is more of a JSON question than a specific couchdb question but...
I know someone on this list has run into this before somewhere.  I need to bring my couch docs into C structs to work with them.  So right now I'm dropping them into file, reading the file, and parsing them field by field into a struct with CJSON.  Seems there has to be a quicker path.  I do still have to have a little work between the doc and the struct, like converting string constants into enums and stuff like that so it can't be too automatic if you know what I mean.

Any ideas?

Re: Simplest path from couch to C?

Posted by Dan Santner <da...@me.com>.
Thanks Mike this looks pretty good for what I'm doing right now.  At least makes the call to get the doc a bit easier :).
On Dec 12, 2013, at 7:55 AM, Mike Marino <mm...@gmail.com> wrote:

> Hey Dan,
> 
> As an option, see pillowtalk started by jubos over on github.  It uses yajl
> as the back end and, though it's tedious to do in C, it is relatively
> straightforward to deal with.  This doesn't make it *automatic* (I don't
> think that would be possible in C given the strong-typedness of the
> language), but perhaps it will be easier than what you're doing now.
> 
> You can also find a forked version here that I've worked on:
> 
> https://github.com/mgmarino/pillowtalk
> 
> that introduces changes feed and support for compilation on windows,
> (though it doesn't sound like you need that).
> 
> Cheers,
> Mike
> 
> 
> On Thu, Dec 12, 2013 at 7:45 AM, Dan Santner <da...@me.com> wrote:
> 
>> Hey guys I know this is more of a JSON question than a specific couchdb
>> question but...
>> I know someone on this list has run into this before somewhere.  I need to
>> bring my couch docs into C structs to work with them.  So right now I'm
>> dropping them into file, reading the file, and parsing them field by field
>> into a struct with CJSON.  Seems there has to be a quicker path.  I do
>> still have to have a little work between the doc and the struct, like
>> converting string constants into enums and stuff like that so it can't be
>> too automatic if you know what I mean.
>> 
>> Any ideas?


Re: Simplest path from couch to C?

Posted by Mike Marino <mm...@gmail.com>.
Hey Dan,

As an option, see pillowtalk started by jubos over on github.  It uses yajl
as the back end and, though it's tedious to do in C, it is relatively
straightforward to deal with.  This doesn't make it *automatic* (I don't
think that would be possible in C given the strong-typedness of the
language), but perhaps it will be easier than what you're doing now.

You can also find a forked version here that I've worked on:

https://github.com/mgmarino/pillowtalk

that introduces changes feed and support for compilation on windows,
(though it doesn't sound like you need that).

Cheers,
Mike


On Thu, Dec 12, 2013 at 7:45 AM, Dan Santner <da...@me.com> wrote:

> Hey guys I know this is more of a JSON question than a specific couchdb
> question but...
> I know someone on this list has run into this before somewhere.  I need to
> bring my couch docs into C structs to work with them.  So right now I'm
> dropping them into file, reading the file, and parsing them field by field
> into a struct with CJSON.  Seems there has to be a quicker path.  I do
> still have to have a little work between the doc and the struct, like
> converting string constants into enums and stuff like that so it can't be
> too automatic if you know what I mean.
>
> Any ideas?

Re: Simplest path from couch to C?

Posted by Travis Paul <Tr...@visPaul.me>.
I use WJElement for working with JSON in C. The main reason I chose this
library is because it's the only JSON library for C that has JSON schema
support (that I know of). It's also pretty easy to use and has some nice
features.

https://github.com/netmail-open/wjelement


On Thu, Dec 12, 2013 at 8:45 AM, Dan Santner <da...@me.com> wrote:

> Hey guys I know this is more of a JSON question than a specific couchdb
> question but...
> I know someone on this list has run into this before somewhere.  I need to
> bring my couch docs into C structs to work with them.  So right now I'm
> dropping them into file, reading the file, and parsing them field by field
> into a struct with CJSON.  Seems there has to be a quicker path.  I do
> still have to have a little work between the doc and the struct, like
> converting string constants into enums and stuff like that so it can't be
> too automatic if you know what I mean.
>
> Any ideas?