[SR-Users] mongodb and jansson

Daniel-Constantin Mierla miconda at gmail.com
Mon Jul 6 13:03:32 CEST 2015


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 at lists.sip-router.org
> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users

-- 
Daniel-Constantin Mierla
http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda
Book: SIP Routing With Kamailio - http://www.asipto.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sip-router.org/pipermail/sr-users/attachments/20150706/0fe1fea0/attachment.html>


More information about the sr-users mailing list