Revision 88b5da7b transports/janus_websockets.c

View differences:

transports/janus_websockets.c
98 98
static gboolean wss_janus_api_enabled = FALSE;
99 99
static gboolean wss_admin_api_enabled = FALSE;
100 100

  
101
/* JSON serialization options */
102
static size_t json_format = JSON_INDENT(3) | JSON_PRESERVE_ORDER;
103

  
101 104

  
102 105
/* Logging */
103 106
static int ws_log_level = 0;
......
360 363
		janus_config_print(config);
361 364

  
362 365
		/* Handle configuration */
363
		janus_config_item *item = janus_config_get_item_drilldown(config, "general", "ws_logging");
366
		janus_config_item *item = janus_config_get_item_drilldown(config, "general", "json");
367
		if(item && item->value) {
368
			/* Check how we need to format/serialize the JSON output */
369
			if(!strcasecmp(item->value, "indented")) {
370
				/* Default: indented, we use three spaces for that */
371
				json_format = JSON_INDENT(3) | JSON_PRESERVE_ORDER;
372
			} else if(!strcasecmp(item->value, "plain")) {
373
				/* Not indented and no new lines, but still readable */
374
				json_format = JSON_INDENT(0) | JSON_PRESERVE_ORDER;
375
			} else if(!strcasecmp(item->value, "compact")) {
376
				/* Compact, so no spaces between separators */
377
				json_format = JSON_COMPACT | JSON_PRESERVE_ORDER;
378
			} else {
379
				JANUS_LOG(LOG_WARN, "Unsupported JSON format option '%s', using default (indented)\n", item->value);
380
				json_format = JSON_INDENT(3) | JSON_PRESERVE_ORDER;
381
			}
382
		}
383

  
384
		item = janus_config_get_item_drilldown(config, "general", "ws_logging");
364 385
		if(item && item->value) {
365 386
			ws_log_level = atoi(item->value);
366 387
			if(ws_log_level < 0)
......
782 803
	}
783 804
	janus_mutex_lock(&client->mutex);
784 805
	/* Convert to string and enqueue */
785
	char *payload = json_dumps(message, JSON_INDENT(3) | JSON_PRESERVE_ORDER);
806
	char *payload = json_dumps(message, json_format);
786 807
	g_async_queue_push(client->messages, payload);
787 808
#ifdef HAVE_LIBWEBSOCKETS_NEWAPI
788 809
	lws_callback_on_writable(client->wsi);

Also available in: Unified diff