akheron / jansson

C library for encoding, decoding and manipulating JSON data
http://www.digip.org/jansson/
Other
3.05k stars 808 forks source link

Is there python support or compatibility for Jansson? #618

Closed tpatki closed 2 years ago

tpatki commented 2 years ago

We have a C library that uses jansson, and we are looking into creating a python wrapper for our C API using ctypes. One issue I'm running into is how to pass the json_t object around from python to the shared library in C. It would be useful to be able to call into the json_object or json_dumps Jansson calls from our python wrapper class, or have a translation between Python's native JSON and the jansson C library.

Does this exist at all, and if not, is there a recommendation from your team on how to address this issue ?

woodz- commented 2 years ago

For me it sounds more like an issue on how to define the python representation of json_t structure than supporting something for python out of a c project.

akheron commented 2 years ago

I'm not familiar with ctypes, but if you can wrap a json_t pointer somehow as an opaque object, then you should be able to call Jansson's functions on it. You don't need to know what's inside a json_t, it's fully opaque even if you use it from C. All usage happens through Jansson's API functions.