when using mongodb with jansson, intermittent failures will be seen because jansson would change the order of keys inside a json object. mongodb would expect the first key to be a command, for example "insert". this is disastrous! below is a fix for jansson which will preserve the order on which the json object was created.
--- modules/jansson/jansson_utils.c.old 2015-07-06 17:41:25.852770681 +0800 +++ modules/jansson/jansson_utils.c 2015-07-06 17:42:27.384769579 +0800 @@ -33,7 +33,7 @@ val->flags = 0;
if(json_is_object(v) || json_is_array(v)) { - const char* value = json_dumps(v, JSON_COMPACT); + const char* value = json_dumps(v, JSON_COMPACT|JSON_PRESERVE_ORDER); *freeme = (char*)value; val->rs.s = (char*)value; val->rs.len = strlen(value);
Kelvin Chua
Hello,
thanks for investigating and providing the patch.
Can you make a pull request on github? The patch is small but can be merged from small devices while traveling and also ensures that it compiles on TravisCI (without a need to compile locally).
Cheers, Daniel
On 06/07/15 11:43, Kelvin Chua wrote:
when using mongodb with jansson, intermittent failures will be seen because jansson would change the order of keys inside a json object. mongodb would expect the first key to be a command, for example "insert". this is disastrous! below is a fix for jansson which will preserve the order on which the json object was created.
--- modules/jansson/jansson_utils.c.old2015-07-06 17:41:25.852770681 +0800 +++ modules/jansson/jansson_utils.c2015-07-06 17:42:27.384769579 +0800 @@ -33,7 +33,7 @@ val->flags = 0;
if(json_is_object(v) || json_is_array(v)) { -const char* value = json_dumps(v, JSON_COMPACT); +const char* value = json_dumps(v, JSON_COMPACT|JSON_PRESERVE_ORDER); *freeme = (char*)value; val->rs.s = (char*)value; val->rs.len = strlen(value);
Kelvin Chua
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users