/*
*打印JSON数据的值
*返回类型: none
*返回值: none
*传入参数json_object *类型
*author  mleaf_hexi
*mail:[email protected]
*/ 
static void json_print_value(json_object *obj) 
{
	char *action="CONFIG_DTS_DEVICE_OPTIONS";
	char *configOption="CLOUD_PLATFORM_WEBSOCKET_URL";

	if(!obj) return;
	json_type type=json_object_get_type(obj);
	if(type == json_type_boolean) {
	    if(json_object_get_boolean(obj)) {
	        printf("true");
	    } else {
	        printf("false");
	    }
	} else if(type == json_type_double) {
	    printf("json_object_get_double=%lf\n",json_object_get_double(obj));
	} else if(type == json_type_int) {
	    printf("json_object_get_int=%d\n",json_object_get_int(obj));
	} 
	else if(type == json_type_string) 
	{
	    
		if(strcmp(json_object_get_string(obj),action)==0)
		{
			printf("action checking out\n");
			printf("action=%s\n",json_object_get_string(obj));
		}
		else if(strcmp(json_object_get_string(obj),configOption)==0)
		{
			printf("configOption checking out\n");
			printf("configOption=%s\n",json_object_get_string(obj));

		}
		else
		{
			printf("json_object_get_string=%s\n",json_object_get_string(obj));
		}
	} 
	else if(type == json_type_object) {
	    json_print_object(obj);
	} else if(type == json_type_array) {
	    json_print_array(obj);
	} else {
	    printf("ERROR");
	}
	printf(" ");
}
Example #2
0
void
json_print_value (json_object * obj)
{
  if (!obj)
    return;
  json_type type = json_object_get_type (obj);
  if (type == json_type_boolean)
    {
      if (json_object_get_boolean (obj))
	{
	  printf ("true");
	}
      else
	{
	  printf ("false");
	}
    }
  else if (type == json_type_double)
    {
      printf ("%lf", json_object_get_double (obj));
    }
  else if (type == json_type_int)
    {
      printf ("%d", json_object_get_int (obj));
    }
  else if (type == json_type_string)
    {
      printf ("%s", json_object_get_string (obj));
    }
  else if (type == json_type_object)
    {
      json_print_object (obj);
    }
  else if (type == json_type_array)
    {
      json_print_array (obj);
    }
  else
    {
      printf ("ERROR");
    }
  printf (" ");
}