[gdal-dev] json-c 0.10 update status and json-c copy removal proposed

Mateusz Loskot mateusz at loskot.net
Fri Jul 13 16:30:16 PDT 2012


I'm trying to update GDAL's copy of json-c library.
The task is not trivial, due to the fact GDAL has applied
some sort of improvements to json-c, and also due to
significant changes to how json-c works, UTF-8 support, etc.

I tried to merge GDAL changes into Git branch at

All GDAL-specific changes are controlled with:


So, geojson and couchdb drivers have got -DGDAL_JSONC_MOD_ENABLED=1
in their makefiles.

Some of GDAL's fixes have been submitted and accepted to the upstream,
but there are a few which hasn't, like custom function
json_object_new_double_with_precision(), or use of CPL string functions.

Personally, I don't really see benefits of using CPL functions in json-c.
The json_object_new_double_with_precision could be moved out to GDAL
source files.
So, if we could compromise and give up on GDAL-specific json-c version,
I'd like to propose to completely remove json-c sources from GDAL
and rely on externally provided json-c (libjsonc)
Especially, that building json-c is versy simple...if its native build
configuration is used.

Maintaining private and *changed* copy of json-c has become painful.
json-c has grown and its configuration/building is based on two
non-trivial config headers
with plenty of #defines. Previously, we simply crafted our own version
of static config.h
that worked for all systems. It is not really feasible with new version.
Also, hosting our own modified copy of json-c may lead to more GDAL-specific
modifications increasing the pain of sync'ing it with upstream and
maintenance in future.

I don't see any reason why GDAL couldn't rely on external json-c.
So, I'd like to propose to:
- remove GDAL's copy of json-c from ogr/ogrsf_frmts/geojson/jsonc
- configure Unix and Windows builds to use external binaries

I'm volunteering to apply those changes.
Please, shall I make RFC, call for votes or this e-mail is sufficient to
discuss and make decision?

The current status is that use of the json-c 0.10 leads to crashes,
they are a bit mysterious and likely related to how json-c handles
character encodings, but I'm trying to confirm that with the json-c folks.

Best regards,
Mateusz Loskot, http://mateusz.loskot.net

More information about the gdal-dev mailing list