Hi,

I am developing a postgres extension. The extension gets json data as a
string from external source and is supposed to be able to store this string
in a Jsonb type.

I am working with C API for postgres-9.4 installed from ubuntu trusty main
repo.

I would like to use a function that converts a cstring to Jsonb* structure
defined in

http://doxygen.postgresql.org/jsonb_8h.html

There are functions doing exactly this already defined in

http://doxygen.postgresql.org/jsonb_8c.html

Namely, the function Datum jsonb_in ( PG_FUNCTION_ARGS ), however I am not
sure if I can call this function from C API in a portable and safe manner.
As it seems it is intended for being called by postgres from first glance.

I could also use the function jsonb_from_cstring

http://doxygen.postgresql.org/jsonb_8c.html#ab23eca28d5880f86a0943d71c90d6654

but it is declared and defined in jsonb.c and not declared in json.h, and
hence linking with this function is not a very clean solution. I tried
finding the symbols for jsonb_from_cstring in libpq.so, however there are
none. I am guessing I need a non-standard build of postgres?

So the question is, what is the best way to convert a cstring to a Jsonb*
structure from within C API?

Thanks,
Igor

Reply via email to