diff --git a/modules/libcom/src/yajl/yajl.c b/modules/libcom/src/yajl/yajl.c index c21e163dd..fdad3f68e 100644 --- a/modules/libcom/src/yajl/yajl.c +++ b/modules/libcom/src/yajl/yajl.c @@ -74,7 +74,7 @@ yajl_alloc(const yajl_callbacks * callbacks, hand->lexer = NULL; hand->bytesConsumed = 0; hand->decodeBuf = yajl_buf_alloc(&(hand->alloc)); - hand->flags = 0; + hand->flags = yajl_allow_json5 | yajl_allow_comments; yajl_bs_init(hand->stateStack, &(hand->alloc)); yajl_bs_push(hand->stateStack, yajl_state_start); diff --git a/modules/libcom/src/yajl/yajl_common.h b/modules/libcom/src/yajl/yajl_common.h index d842aa5bf..fca8454a8 100644 --- a/modules/libcom/src/yajl/yajl_common.h +++ b/modules/libcom/src/yajl/yajl_common.h @@ -37,13 +37,27 @@ extern "C" { * YAJL 1.0.12 version that was * bundled with EPICS Base 3.15.0.1 * - * YAJL 2.1.0 + * ***YAJL 2.1.0*** * \li Changes argument type for yajl_integer() from \c int to \c long \c long - * \li Changes argument type for yajl_string() and yajl_map_key() from \c unsigned to \c size_t + * \li Changes argument type for yajl_string() and yajl_map_key() from + * \c unsigned to \c size_t * \li Replacement of struct yajl_parser_config with yajl_config() * \li Replacement of yajl_parse_complete() with yajl_complete_parse() + * + * ***YAJL 2.2.0*** + * This version adds support for JSON5 parsing and generation. + * The upstream YAJL repository is no longer being maintained and the + * original author no longer responds to messsages, so while this code + * has been offered for merging into the upstream it is unlikely that + * will ever happen. The version number here is thus an EPICS-specific + * construct. */ -#define EPICS_YAJL_VERSION VERSION_INT(2,1,0,0) +#define EPICS_YAJL_VERSION VERSION_INT(2,2,0,0) + +/** A macro to make it easy to conditionally compile code that supports + * older releases. + */ +#define HAS_JSON5 /** A limit used by the generator API, YAJL_MAX_DEPTH is the maximum * depth to which arrays and maps may be nested. diff --git a/modules/libcom/src/yajl/yajl_parse.h b/modules/libcom/src/yajl/yajl_parse.h index 09ab546ff..90367d978 100644 --- a/modules/libcom/src/yajl/yajl_parse.h +++ b/modules/libcom/src/yajl/yajl_parse.h @@ -183,7 +183,8 @@ extern "C" { * and object keys which are not permitted by the JSON standard. * Setting this flag tells yajl to accept JSON5 standard input. * This flag also enables \c yajl_allow_comments since comments are - * part of the JSON5 standard. + * part of the JSON5 standard. In the EPICS build this option is + * enabled by default, it must be turned off to disable JSON5. * * yajl_config() argument type: int (boolean) * diff --git a/modules/libcom/test/yajl_test.c b/modules/libcom/test/yajl_test.c index 079366680..be92aecfd 100644 --- a/modules/libcom/test/yajl_test.c +++ b/modules/libcom/test/yajl_test.c @@ -205,6 +205,9 @@ main(int argc, char ** argv) /* allocate the parser */ hand = yajl_alloc(&callbacks, &allocFuncs, NULL); + /* turn off JSON5 (the EPICS default) */ + yajl_config(hand, yajl_allow_json5, 0); + /* check arguments. We expect exactly one! */ for (i=1;i