• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ JSON_INDENT函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中JSON_INDENT函数的典型用法代码示例。如果您正苦于以下问题:C++ JSON_INDENT函数的具体用法?C++ JSON_INDENT怎么用?C++ JSON_INDENT使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了JSON_INDENT函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: ZnpActorPublishDeviceLqi

void ZnpActorPublishDeviceLqi(WORD nAddress, BYTE nLqi)
{
	PDEVICEINFO pDevice;
	if (pZnpActor == NULL) return;
	pDevice = DeviceFind(nAddress);
	if (pDevice == NULL) return;
	json_t* eventJson = json_object();
	json_t* paramsJson = json_object();
	char* macIdString = IeeeToString(pDevice->IeeeAddr);
	json_t* macIdJson = json_string(macIdString);
	json_t* lqiJson = NULL;
	free(macIdString);
	json_t* protocolJson = json_string("zigbee");
	if (nLqi > LQI_LIMIT)
		lqiJson = json_integer(1);
	else
		lqiJson = json_integer(0);
	json_object_set(paramsJson, "macId", macIdJson);
	json_object_set(paramsJson, "protocol", protocolJson);
	json_object_set(paramsJson, "signal_strength", lqiJson);
	json_object_set(eventJson, "params", paramsJson);
	char* eventMessage = json_dumps(eventJson, JSON_INDENT(4) | JSON_REAL_PRECISION(4));
	//char* topicName = ActorMakeTopicName(pZnpActor->guid, "/:event/device_signal");
	char* topicName = ActorMakeTopicName("event/", pZnpActor->guid, "/device_signal");
	ActorSend(pZnpActor, topicName, eventMessage, NULL, FALSE, topicName);
	json_decref(lqiJson);
	json_decref(protocolJson);
	json_decref(macIdJson);
	json_decref(paramsJson);
	json_decref(eventJson);
	free(topicName);
	free(eventMessage);
}
开发者ID:chaunm,项目名称:znp-service,代码行数:33,代码来源:ZnpActor.c


示例2: ZnpActorPublishEndpointAddedEvent

void ZnpActorPublishEndpointAddedEvent(IEEEADDRESS macId, BYTE endpoint, WORD deviceId, WORD deviceType)
{
	if (pZnpActor == NULL) return;
	json_t* eventJson = json_object();
	json_t* paramsJson = json_object();
	char* eventMessage;
	char* topicName;
	char* macIdString = IeeeToString(macId);
	json_t* macJson = json_string(macIdString);
	free(macIdString);
	json_object_set(paramsJson, "macId", macJson);
	json_decref(macJson);
	char* endpointString = malloc(20);
	sprintf(endpointString, "%d", endpoint);
	json_t* endpointJson = json_string(endpointString);
	free(endpointString);
	json_object_set(paramsJson, "endpoint", endpointJson);
	json_decref(endpointJson);
	json_t* deviceClassJson;
	deviceClassJson = DevDesMakeDeviceClassJson(deviceId, deviceType);
	json_object_set(paramsJson, "class", deviceClassJson);
	json_decref(deviceClassJson);
	json_t* protocolJson = json_string("zigbee");
	json_object_set(paramsJson, "protocol", protocolJson);
	json_decref(protocolJson);
	json_object_set(eventJson, "params", paramsJson);
	json_decref(paramsJson);
	eventMessage = json_dumps(eventJson, JSON_INDENT(4) | JSON_REAL_PRECISION(4));
	json_decref(eventJson);
	//topicName = ActorMakeTopicName(pZnpActor->guid, "/:event/endpoint_added");
	topicName = ActorMakeTopicName("event/", pZnpActor->guid, "/endpoint_added");
	ActorSend(pZnpActor, topicName, eventMessage, NULL, FALSE, topicName);
	free(eventMessage);
	free(topicName);
}
开发者ID:chaunm,项目名称:znp-service,代码行数:35,代码来源:ZnpActor.c


示例3: ZnpActorPublishDeviceErrorEvent

void ZnpActorPublishDeviceErrorEvent(IEEEADDRESS macId, WORD error)
{
	if (pZnpActor == NULL) return;
	json_t* eventJson = json_object();
	json_t* paramsJson = json_object();
	char* macIdString = IeeeToString(macId);
	json_t* macIdJson = json_string(macIdString);
	free(macIdString);
	json_t* protocolJson = json_string("zigbee");
	char* errorMessage = malloc(50);
	sprintf(errorMessage, "%s%d","error.actor.", error);
	json_t* errorJson = json_string(errorMessage);
	free(errorMessage);
	json_object_set(paramsJson, "macId", macIdJson);
	json_object_set(paramsJson, "protocol", protocolJson);
	json_object_set(paramsJson, "error", errorJson);
	json_object_set(eventJson, "params", paramsJson);
	char* eventMessage = json_dumps(eventJson, JSON_INDENT(4) | JSON_REAL_PRECISION(4));
	//char* topicName = ActorMakeTopicName(pZnpActor->guid, "/:event/device_error");
	char* topicName = ActorMakeTopicName("event/", pZnpActor->guid, "/device_error");
	ActorSend(pZnpActor, topicName, eventMessage, NULL, FALSE, topicName);
	json_decref(errorJson);
	json_decref(protocolJson);
	json_decref(macIdJson);
	json_decref(paramsJson);
	json_decref(eventJson);
	free(topicName);
	free(eventMessage);
}
开发者ID:chaunm,项目名称:znp-service,代码行数:29,代码来源:ZnpActor.c


示例4: janus_websockets_send_message

int janus_websockets_send_message(void *transport, void *request_id, gboolean admin, json_t *message) {
	if(message == NULL)
		return -1;
	if(transport == NULL) {
		g_free(message);
		return -1;
	}
	/* Make sure this is not related to a closed /freed WebSocket session */
	janus_mutex_lock(&old_wss_mutex);
	janus_websockets_client *client = (janus_websockets_client *)transport;
	if(g_list_find(old_wss, client) != NULL) {
		g_free(message);
		message = NULL;
		transport = NULL;
	} else if(!client->context || !client->wsi) {
		g_free(message);
		message = NULL;
	}
	if(message == NULL) {
		janus_mutex_unlock(&old_wss_mutex);
		return -1;
	}
	janus_mutex_lock(&client->mutex);
	/* Convert to string and enqueue */
	char *payload = json_dumps(message, JSON_INDENT(3) | JSON_PRESERVE_ORDER);
	g_async_queue_push(client->messages, payload);
	libwebsocket_callback_on_writable(client->context, client->wsi);
	janus_mutex_unlock(&client->mutex);
	janus_mutex_unlock(&old_wss_mutex);
	json_decref(message);
	return 0;
}
开发者ID:Zhang,项目名称:Streame,代码行数:32,代码来源:janus_websockets.c


示例5: fprintf

/* encode_json : encode the exnode in the JSON format n dump it in string
 * dir : directory name
 * parent_id : parent directory id
 * return : JSON dump of exnode
 *
 */
char *encode_json(const char *dir, const char *parent_id){
	
	if(dir == NULL){
		fprintf(stderr, "Invalid directory name \n");
		return NULL;
	}
	
	// create json object
	json_t *json_exnode = json_object();
	json_object_set(json_exnode, "name", json_string(dir));
	json_object_set(json_exnode, "created", json_integer(time(NULL)));
	json_object_set(json_exnode, "modified", json_integer(time(NULL)));
	json_object_set(json_exnode, "mode", json_string("directory"));
	json_object_set(json_exnode, "size", json_integer(0));

	if (parent_id == NULL) {
	  json_object_set(json_exnode, "parent", json_null());
	}
	else {
	  json_t *pobj = json_object();
	  json_object_set(pobj, "href", json_string(parent_id));
	  json_object_set(pobj, "rel", json_string("full"));
	  json_object_set(json_exnode, "parent", pobj);
	}
	
	return json_dumps(json_exnode, JSON_INDENT(1));
}
开发者ID:periscope-ps,项目名称:libunis-c,代码行数:33,代码来源:unis_exnode.c


示例6: w_state_save

bool w_state_save(void)
{
  json_t *state;
  w_jbuffer_t buffer;
  int fd = -1;
  char tmpname[WATCHMAN_NAME_MAX];
  bool result = false;

  if (dont_save_state) {
    return true;
  }

  pthread_mutex_lock(&state_lock);

  state = json_object();

  if (!w_json_buffer_init(&buffer)) {
    w_log(W_LOG_ERR, "save_state: failed to init json buffer\n");
    goto out;
  }

  snprintf(tmpname, sizeof(tmpname), "%sXXXXXX",
      watchman_state_file);
  fd = w_mkstemp(tmpname);
  if (fd == -1) {
    w_log(W_LOG_ERR, "save_state: unable to create temporary file: %s\n",
        strerror(errno));
    goto out;
  }

  json_object_set_new(state, "version", json_string(PACKAGE_VERSION));

  /* now ask the different subsystems to fill out the state */
  if (!w_root_save_state(state)) {
    goto out;
  }

  /* we've prepared what we're going to save, so write it out */
  w_json_buffer_write(&buffer, fd, state, JSON_INDENT(4));

  /* atomically replace the old contents */
  result = rename(tmpname, watchman_state_file) == 0;

out:
  if (state) {
    json_decref(state);
  }
  w_json_buffer_free(&buffer);
  if (fd != -1) {
    if (!result) {
      // If we didn't succeed, remove our temporary file
      unlink(tmpname);
    }
    close(fd);
  }

  pthread_mutex_unlock(&state_lock);

  return result;
}
开发者ID:jadedgnome,项目名称:watchman,代码行数:60,代码来源:state.c


示例7: ZnpActorPublishDeviceDataEvent

void ZnpActorPublishDeviceDataEvent(IEEEADDRESS macId, BYTE endPoint, BYTE nDataCount, PZNPACTORDATA *pData)
{
	if (pZnpActor == NULL) return;
	json_t* eventJson = json_object();
	json_t* paramsJson = json_object();
	char* macIdString = IeeeToString(macId);
	json_t* macIdJson = json_string(macIdString);
	free(macIdString);
	char* endpointString = malloc(20);
	sprintf(endpointString, "%d", endPoint);
	json_t* endpointJson = json_string(endpointString);
	free(endpointString);
	json_t* protocolJson = json_string("zigbee");
	json_object_set(paramsJson, "macId", macIdJson);
	json_object_set(paramsJson, "endpoint", endpointJson);
	json_object_set(paramsJson, "protocol", protocolJson);
	json_decref(macIdJson);
	json_decref(endpointJson);
	json_decref(protocolJson);
	json_t* dataJson;
	json_t* valueJson;
	dataJson = json_object();
	BYTE nIndex = 0;
	while (nDataCount > 0)
	{
		switch (pData[nIndex]->nDataType)
		{
		case ZNP_DATA_TYPE_INTERGER:
			valueJson = json_integer((int)(*((int*)(pData[nIndex]->value))));
			break;
		case ZNP_DATA_TYPE_FLOAT:
			valueJson = json_real((double)(*((double*)(pData[nIndex]->value))));
			break;
		case ZNP_DATA_TYPE_STRING:
			valueJson = json_string(pData[nIndex]->value);
			break;
		default:
			json_decref(dataJson);
			json_decref(paramsJson);
			json_decref(eventJson);
			return;
			break;
		}
		json_object_set(dataJson, pData[nIndex]->dataName, valueJson);
		json_decref(valueJson);
		nDataCount--;
		nIndex++;
	}
	json_object_set(paramsJson, "data", dataJson);
	json_decref(dataJson);
	json_object_set(eventJson, "params", paramsJson);
	json_decref(paramsJson);
	char* eventMessage = json_dumps(eventJson, JSON_INDENT(4) | JSON_REAL_PRECISION(4));
	json_decref(eventJson);
	//char* topicName = ActorMakeTopicName(pZnpActor->guid, "/:event/device_data");
	char* topicName = ActorMakeTopicName("event/", pZnpActor->guid, "/device_data");
	ActorSend(pZnpActor, topicName, eventMessage, NULL, FALSE, topicName);
	free(topicName);
	free(eventMessage);
}
开发者ID:chaunm,项目名称:znp-service,代码行数:60,代码来源:ZnpActor.c


示例8: send_metric

static struct MHD_Response *
send_metric(struct brubeck_server *server, const char *url)
{
    static const char *metric_types[] = {
        "gauge", "meter", "counter", "histogram", "timer", "internal"
    };
    static const char *expire_status[] = {
        "disabled", "inactive", "active"
    };

    struct brubeck_metric *metric = safe_lookup_metric(
                                        server, url + strlen("/metric/"));

    if (metric) {
        json_t *mj = json_pack("{s:s, s:s, s:i, s:s}",
                               "key", metric->key,
                               "type", metric_types[metric->type],
#if METRIC_SHARD_SPECIFIER
                               "shard", (int)metric->shard,
#else
                               "shard", 0,
#endif
                               "expire", expire_status[metric->expire]
                              );

        char *jsonr = json_dumps(mj, JSON_INDENT(4) | JSON_PRESERVE_ORDER);
        json_decref(mj);
        return MHD_create_response_from_data(
                   strlen(jsonr), jsonr, 1, 0);
    }

    return NULL;
}
开发者ID:bwilber,项目名称:brubeck,代码行数:33,代码来源:http.c


示例9: janus_echotest_hangup_media

void janus_echotest_hangup_media(janus_plugin_session *handle) {
	JANUS_LOG(LOG_INFO, "No WebRTC media anymore\n");
	if(stopping || !initialized)
		return;
	janus_echotest_session *session = (janus_echotest_session *)handle->plugin_handle;
	if(!session) {
		JANUS_LOG(LOG_ERR, "No session associated with this handle...\n");
		return;
	}
	if(session->destroyed)
		return;
	/* Send an event to the browser and tell it's over */
	json_t *event = json_object();
	json_object_set_new(event, "echotest", json_string("event"));
	json_object_set_new(event, "result", json_string("done"));
	char *event_text = json_dumps(event, JSON_INDENT(3) | JSON_PRESERVE_ORDER);
	json_decref(event);
	JANUS_LOG(LOG_VERB, "Pushing event: %s\n", event_text);
	int ret = gateway->push_event(handle, &janus_echotest_plugin, NULL, event_text, NULL, NULL);
	JANUS_LOG(LOG_VERB, "  >> %d (%s)\n", ret, janus_get_api_error(ret));
	g_free(event_text);
	/* Reset controls */
	session->audio_active = TRUE;
	session->video_active = TRUE;
	session->bitrate = 0;
}
开发者ID:mporrato,项目名称:janus-gateway,代码行数:26,代码来源:janus_echotest.c


示例10: blkmk_submit_jansson

void SubmitContext::submitBlock(blktemplate_t *blockTemplate,
                                const PrimecoinBlockHeader &header,
                                unsigned dataId)
{
  json_t *jsonBlock =
    blkmk_submit_jansson(blockTemplate,
                         (unsigned char*)&header,
                         dataId,
                         __builtin_bswap32(header.nonce),
                         header.multiplier,
                         header.multiplier[0]+1);
  char *request = json_dumps(jsonBlock, JSON_INDENT(2));
  json_delete(jsonBlock);
  
  _response.clear();
  logFormattedWrite(_log, "submit request: %s", request);
  curl_easy_setopt(curl, CURLOPT_POSTFIELDS, request);
  if (curl_easy_perform(curl) != CURLE_OK) {
    logFormattedWrite(_log, "block send error!!!");
  } else {
    logFormattedWrite(_log, "response: %s");
  }
  
  free(request);
}
开发者ID:schwertfjo,项目名称:xpmminer,代码行数:25,代码来源:getblocktemplate.cpp


示例11: cd_JSONRequest

static
void
cd_JSONRequest (struct evhttp_request* request, CDServer* server)
{
    struct evbuffer* buffer = evhttp_request_get_input_buffer(request);
    char*            text   = CD_alloc(evbuffer_get_length(buffer) + 1);

    evbuffer_remove(buffer, text, evbuffer_get_length(buffer));

    json_error_t error;
    json_t*      input  = json_loads(text, 0, &error);
    json_t*      output = json_object();

    printf("%s\n", text);

    if (evhttp_request_get_command(request) != EVHTTP_REQ_POST) {
        goto error;
    }

    if (input == NULL) {
        SERR(server, "RPC.JSON: error on line %d: %s", error.line, error.text);

        goto error;
    }

    CD_EventDispatch(server, "RPC.JSON", input, output);

done: {
        char*            outString = json_dumps(output, JSON_INDENT(2));
        struct evbuffer* outBuffer = evbuffer_new();

        evbuffer_add_printf(outBuffer, "%s", outString);

        evhttp_send_reply(request, HTTP_OK, "OK", outBuffer);

        evbuffer_free(outBuffer);
        free(outString);
        json_delete(output);
        json_delete(input);
        CD_free(text);

        return;
    }

error: {
        evhttp_send_error(request, HTTP_INTERNAL, "Internal server error");

        CD_free(text);

        if (input) {
            json_delete(input);
        }

        if (output) {
            json_delete(output);
        }

        return;
    }
}
开发者ID:Youx,项目名称:craftd,代码行数:60,代码来源:HTTPd.c


示例12: on_list_update

void on_list_update(struct DSLink *link, ref_t *req_ref, json_t *resp) {
    (void) link;
    RequestHolder *holder = req_ref->data;

    json_t *updates = json_object_get(resp, "updates");
    size_t index;
    json_t *value;

    const char* path = json_string_value(json_object_get(holder->req, "path"));

    printf("======= List %s =======\n", path);
    json_array_foreach(updates, index, value) {
        json_t *name = json_array_get(value, 0);
        json_t *val = json_array_get(value, 1);

        if (val->type == JSON_ARRAY || val->type == JSON_OBJECT) {
            char *data = json_dumps(val, JSON_INDENT(0));
            printf("%s = %s\n", json_string_value(name), data);
            dslink_free(data);
        } else if (val->type == JSON_STRING) {
            printf("%s = %s\n", json_string_value(name), json_string_value(val));
        } else if (val->type == JSON_INTEGER) {
            printf("%s = %lli\n", json_string_value(name), json_integer_value(val));
        } else if (val->type == JSON_REAL) {
            printf("%s = %f\n", json_string_value(name), json_real_value(val));
        } else if (val->type == JSON_NULL) {
            printf("%s = NULL\n", json_string_value(name));
        } else if (val->type == JSON_TRUE) {
            printf("%s = true\n", json_string_value(name));
        } else if (val->type == JSON_FALSE) {
            printf("%s = false\n", json_string_value(name));
        } else {
            printf("%s = (Unknown Type)\n", json_string_value(name));
        }
    }
开发者ID:ghalwasi,项目名称:c-mlib,代码行数:35,代码来源:main.c


示例13: saveRevenueMovements

void saveRevenueMovements(char * save_path)
{
    json_t * json_revenue = json_object();
    
    json_t * array = json_array();

    json_t * json_total = json_real(total);
    
    for (struct revenue * revenue = firstRevenueMovement; revenue!=0; revenue=revenue->next)
    {
        json_array_append(array, createRevenueArray(revenue));
    }
    
    int i  = json_object_set(json_revenue, "total", json_total);
    
    int j  = json_object_set(json_revenue, "revenue", array);
    
    if (i == -1 || j == -1)
    {
        printf("errore non è possibile scrivere il file");
    }
    
    json_dump_file(json_revenue, strcat(save_path, "/revenue.json"), JSON_INDENT(3));
    
}
开发者ID:faleandroid,项目名称:BankAccount,代码行数:25,代码来源:main.c


示例14: send_metric

static int send_metric(struct mg_connection *conn)
{
	static const char *metric_types[] = {
		"gauge", "meter", "counter", "histogram", "timer", "internal"
	};
	static const char *expire_status[] = {
		"disabled", "inactive", "active"
	};

	struct brubeck_server *server = conn->server_param;
	struct brubeck_metric *metric = safe_lookup_metric(
			server, conn->uri + strlen("/metric/"));

	if (metric) {
		json_t *mj = json_pack("{s:s, s:s, s:i, s:s}",
			"key", metric->key,
			"type", metric_types[metric->type],
#if METRIC_SHARD_SPECIFIER
			"shard", (int)metric->shard,
#else
			"shard", 0,
#endif
			"expire", expire_status[metric->expire]
		);

		send_headers(conn);
		json_dump_callback(mj, &dump_json, (void *)conn,
				JSON_INDENT(4) | JSON_PRESERVE_ORDER);
		json_decref(mj);
		return MG_TRUE;
	}

	return MG_FALSE;
}
开发者ID:evelynmitchell,项目名称:brubeck,代码行数:34,代码来源:http.c


示例15: JANUS_LOG

char *janus_serial_query_session(janus_plugin_session *handle) {
	if(g_atomic_int_get(&stopping) || !g_atomic_int_get(&initialized)) {
		return NULL;
	}	
	janus_serial_session *session = (janus_serial_session *)handle->plugin_handle;
	if(!session) {
		JANUS_LOG(LOG_ERR, "No session associated with this handle...\n");
		return NULL;
	}
	/* In the echo test, every session is the same: we just provide some configure info */
	json_t *info = json_object();
	json_object_set_new(info, "audio_active", json_string(session->audio_active ? "true" : "false"));
	json_object_set_new(info, "video_active", json_string(session->video_active ? "true" : "false"));
	json_object_set_new(info, "bitrate", json_integer(session->bitrate));
	if(session->arc || session->vrc) {
		json_t *recording = json_object();
		if(session->arc && session->arc->filename)
			json_object_set_new(recording, "audio", json_string(session->arc->filename));
		if(session->vrc && session->vrc->filename)
			json_object_set_new(recording, "video", json_string(session->vrc->filename));
		json_object_set_new(info, "recording", recording);
	}
	json_object_set_new(info, "slowlink_count", json_integer(session->slowlink_count));
	json_object_set_new(info, "destroyed", json_integer(session->destroyed));
	char *info_text = json_dumps(info, JSON_INDENT(3) | JSON_PRESERVE_ORDER);
	json_decref(info);
	return info_text;
}
开发者ID:kmos,项目名称:janusb,代码行数:28,代码来源:libjanus_serial2.c


示例16: janus_streaming_setup_media

void janus_streaming_setup_media(janus_plugin_session *handle) {
	JANUS_LOG(LOG_INFO, "WebRTC media is now available\n");
	if(stopping || !initialized)
		return;
	janus_streaming_session *session = (janus_streaming_session *)handle->plugin_handle;	
	if(!session) {
		JANUS_LOG(LOG_ERR, "No session associated with this handle...\n");
		return;
	}
	if(session->destroy)
		return;
	/* TODO Only start streaming when we get this event */
	session->started = TRUE;
	/* Prepare JSON event */
	json_t *event = json_object();
	json_object_set_new(event, "streaming", json_string("event"));
	json_t *result = json_object();
	json_object_set_new(result, "status", json_string("started"));
	json_object_set(event, "result", result);
	char *event_text = json_dumps(event, JSON_INDENT(3));
	json_decref(event);
	json_decref(result);
	JANUS_LOG(LOG_VERB, "Pushing event: %s\n", event_text);
	int ret = gateway->push_event(handle, &janus_streaming_plugin, NULL, event_text, NULL, NULL);
	JANUS_LOG(LOG_VERB, "  >> %d (%s)\n", ret, janus_get_api_error(ret));
	g_free(event_text);
}
开发者ID:michaelsharpe,项目名称:janus-gateway,代码行数:27,代码来源:janus_streaming.c


示例17: JANUS_LOG

char *janus_videocall_query_session(janus_plugin_session *handle) {
	if(g_atomic_int_get(&stopping) || !g_atomic_int_get(&initialized)) {
		return NULL;
	}	
	janus_videocall_session *session = (janus_videocall_session *)handle->plugin_handle;
	if(!session) {
		JANUS_LOG(LOG_ERR, "No session associated with this handle...\n");
		return NULL;
	}
	/* Provide some generic info, e.g., if we're in a call and with whom */
	json_t *info = json_object();
	json_object_set_new(info, "state", json_string(session->peer ? "incall" : "idle"));
	json_object_set_new(info, "username", session->username ? json_string(session->username) : NULL);
	if(session->peer) {
		json_object_set_new(info, "peer", session->peer->username ? json_string(session->peer->username) : NULL);
		json_object_set_new(info, "audio_active", json_string(session->audio_active ? "true" : "false"));
		json_object_set_new(info, "video_active", json_string(session->video_active ? "true" : "false"));
		json_object_set_new(info, "bitrate", json_integer(session->bitrate));
		json_object_set_new(info, "slowlink_count", json_integer(session->slowlink_count));
	}
	json_object_set_new(info, "destroyed", json_integer(session->destroyed));
	char *info_text = json_dumps(info, JSON_INDENT(3) | JSON_PRESERVE_ORDER);
	json_decref(info);
	return info_text;
}
开发者ID:Chicooz,项目名称:janus-gateway,代码行数:25,代码来源:janus_videocall.c


示例18: print_config_schema_json

bool print_config_schema_json(POOL_MEM &buffer)
{
   RES_TABLE *resources = my_config->m_resources;

   initialize_json();

   json_t *json = json_object();
   json_object_set_new(json, "format-version", json_integer(2));
   json_object_set_new(json, "component", json_string("bconsole"));
   json_object_set_new(json, "version", json_string(VERSION));

   /*
    * Resources
    */
   json_t *resource = json_object();
   json_object_set(json, "resource", resource);
   json_t *bconsole = json_object();
   json_object_set(resource, "bconsole", bconsole);

   for (int r = 0; resources[r].name; r++) {
      RES_TABLE resource = my_config->m_resources[r];
      json_object_set(bconsole, resource.name, json_items(resource.items));
   }

   pm_strcat(buffer, json_dumps(json, JSON_INDENT(2)));
   json_decref(json);

   return true;
}
开发者ID:gearsforwork,项目名称:bareos,代码行数:29,代码来源:console_conf.c


示例19: on_invoke_updates

void on_invoke_updates(struct DSLink *link, ref_t *req_ref, json_t *resp) {
    (void) link;
    (void) req_ref;
    char *data = json_dumps(resp, JSON_INDENT(2));
    printf("Got invoke %s\n", data);
    dslink_free(data);
}
开发者ID:ghalwasi,项目名称:c-mlib,代码行数:7,代码来源:main.c


示例20: janus_videocall_hangup_media

void janus_videocall_hangup_media(janus_plugin_session *handle) {
	JANUS_LOG(LOG_INFO, "No WebRTC media anymore\n");
	if(stopping || !initialized)
		return;
	janus_videocall_session *session = (janus_videocall_session *)handle->plugin_handle;	
	if(!session) {
		JANUS_LOG(LOG_ERR, "No session associated with this handle...\n");
		return;
	}
	if(session->destroy)
		return;
	janus_mutex_lock(&sessions_mutex);
	if(session->peer) {
		/* Send event to our peer too */
		json_t *call = json_object();
		json_object_set_new(call, "videocall", json_string("event"));
		json_t *calling = json_object();
		json_object_set_new(calling, "event", json_string("hangup"));
		json_object_set_new(calling, "username", json_string(session->username));
		json_object_set_new(calling, "reason", json_string("Remote hangup"));
		json_object_set_new(call, "result", calling);
		char *call_text = json_dumps(call, JSON_INDENT(3) | JSON_PRESERVE_ORDER);
		json_decref(call);
		JANUS_LOG(LOG_VERB, "Pushing event to peer: %s\n", call_text);
		int ret = gateway->push_event(session->peer->handle, &janus_videocall_plugin, NULL, call_text, NULL, NULL);
		JANUS_LOG(LOG_VERB, "  >> %d (%s)\n", ret, janus_get_api_error(ret));
		g_free(call_text);
	}
	session->peer = NULL;
	/* Reset controls */
	session->audio_active = TRUE;
	session->video_active = TRUE;
	session->bitrate = 0;
	janus_mutex_unlock(&sessions_mutex);
}
开发者ID:weidezhang,项目名称:janus-gateway,代码行数:35,代码来源:janus_videocall.c



注:本文中的JSON_INDENT函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ JSON_NODE_TYPE函数代码示例发布时间:2022-05-30
下一篇:
C++ JSON_FAIL_MESSAGE函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap