Ejemplo n.º 1
0
static cJSON *create_config_request_with_name_of_wrong_type(void)
{
	cJSON *params = cJSON_CreateObject();
	cJSON_AddFalseToObject(params, "debug");
	cJSON_AddFalseToObject(params, "name");
	return params;
}
Ejemplo n.º 2
0
void create_conf(GETS4_CONFIG *new_pools,char* fileName)
{
    cJSON *root,*fld,*array;
    char *out;
    FILE* fp = fopen(fileName, "w+");
     if(fp==NULL)
    {
     printf("open error\n");
    }

    root=cJSON_CreateObject();
	cJSON_AddItemToObject(root, "pools", array=cJSON_CreateArray());;
    int i;
    for(i=0;i<3;i++)
    {
    cJSON_AddItemToArray(array,fld=cJSON_CreateObject());
    cJSON_AddStringToObject(fld, "url", new_pools->pools_data[i].url);
    cJSON_AddStringToObject(fld, "user", new_pools->pools_data[i].user);
    cJSON_AddStringToObject(fld, "pass", new_pools->pools_data[i].pass);
    }
    //cJSON_AddStringToObject(root, "api-listen", new_pools->api_listen);
    //cJSON_AddStringToObject(root, "api-network",new_pools->api_network);
    if(1==new_pools->api_listen)
     cJSON_AddTrueToObject(root, "api-listen");
    else if(0==new_pools->api_listen)
     cJSON_AddFalseToObject(root, "api-listen");

    if(1==new_pools->api_network)
     cJSON_AddTrueToObject(root, "api-network");
    else if(0==new_pools->api_network)
     cJSON_AddFalseToObject(root, "api-network");

    if(1==new_pools->bitmain_nobeeper)
     cJSON_AddTrueToObject(root, "bitmain-nobeeper");
	if(1==new_pools->bitmain_notempoverctrl)
     cJSON_AddTrueToObject(root, "bitmain-notempoverctrl");

    cJSON_AddStringToObject(root, "api-allow" , new_pools->api_allow);
    cJSON_AddStringToObject(root, "bitmain-freq", new_pools->bitmain_freq);
    cJSON_AddStringToObject(root, "bitmain-voltage", new_pools->bitmain_voltage);

    out=cJSON_Print(root);
    /*//
    //no use
     char *more_str=",\n    \"api-listen\":	true,\n     \"api-network\":	true\n}";
     i=strlen(out);
     out[i-2]='\0';
     out=(char *)realloc(out,(i+50)*sizeof(char));
     strcat(out,more_str);
   //*/
    fprintf(fp,"%s",out);
    fclose(fp);

    cJSON_Delete(root);
    free(out);
    out = NULL;
    root = NULL;

}
Ejemplo n.º 3
0
static void cjson_add_false_should_fail_with_null_pointers(void)
{
    cJSON *root = cJSON_CreateObject();

    TEST_ASSERT_NULL(cJSON_AddFalseToObject(NULL, "false"));
    TEST_ASSERT_NULL(cJSON_AddFalseToObject(root, NULL));

    cJSON_Delete(root);
}
Ejemplo n.º 4
0
int PublishData(jNet *pJnet, int source)
{
    int res;

    cJSON *root, *son1, *son2;
    char *out;

    root = cJSON_CreateArray();

    cJSON_AddItemToArray(root, son1=cJSON_CreateObject());
    cJSON_AddStringToObject(son1, "hwid", gAgent);
    cJSON_AddStringToObject(son1, "type", "AGENT");
    cJSON_AddItemToObject(son1, "values", son2=cJSON_CreateObject());
    cJSON_AddNumberToObject(son2, "temperature", GetRandTemp());
    if (source == 0)  cJSON_AddFalseToObject(son2, "error");
    else cJSON_AddTrueToObject(son2, "error");

    cJSON_AddItemToArray(root, son1=cJSON_CreateObject());
    cJSON_AddStringToObject(son1, "hwid", "ABCDEF0123456");
    cJSON_AddStringToObject(son1, "type", "SENSOR");
    cJSON_AddItemToObject(son1, "values", son2=cJSON_CreateObject());
    cJSON_AddNumberToObject(son2, "lumen", Read8591(0));
    cJSON_AddNumberToObject(son2, "Volt", Read8591(3));

    out=cJSON_PrintUnformatted(root);
    cJSON_Delete(root);
    printf("Publishing %s\n", out);

    res = jNetPublishT(pJnet, gTopicUp, out);
    //printf("result %d\n", res);
    free(out);
    return res;
}
Ejemplo n.º 5
0
static cJSON *create_config_request_with_name(const char *name)
{
	cJSON *params = cJSON_CreateObject();
	cJSON_AddFalseToObject(params, "debug");
	cJSON_AddStringToObject(params, "name", name);
	return params;
}
Ejemplo n.º 6
0
    void Client::startGame(bool isDefaultLogic, std::string firstTurn)
    {
        if((_state != ConnectionState::connected) || (_socket == NULL)){
            if(_turnlistener != NULL)
			{
				_turnlistener->onStartGameDone(ResultCode::connection_error);
			}
            return;
        }
        
        int byteLen;
        byte *req;
        
        std::string payload;
        cJSON *payloadJSON;
        payloadJSON = cJSON_CreateObject();
        if(isDefaultLogic == true)
            cJSON_AddTrueToObject(payloadJSON, "isDefaultLogic");
        else
            cJSON_AddFalseToObject(payloadJSON, "isDefaultLogic");
        cJSON_AddStringToObject(payloadJSON, "nextTurn", firstTurn.c_str());
        char *cRet =  cJSON_PrintUnformatted(payloadJSON);
        payload = cRet;
        
		req = buildWarpRequest(RequestType::start_game, payload, byteLen);
        
		_socket->sockSend((char*)req, byteLen);
        
        delete[] req;
        cJSON_Delete(payloadJSON);
        free(cRet);
    }
Ejemplo n.º 7
0
void JSONItem::append(const JSONItem& element)
{
    if(!_json) { return; }

    switch(element.getType()) {
    case cJSON_False:
        cJSON_AddFalseToObject(_json, element.getName().mb_str(wxConvUTF8).data());
        break;

    case cJSON_True:
        cJSON_AddTrueToObject(_json, element.getName().mb_str(wxConvUTF8).data());
        break;

    case cJSON_NULL:
        cJSON_AddNullToObject(_json, element.getName().mb_str(wxConvUTF8).data());
        break;

    case cJSON_Number:
        cJSON_AddNumberToObject(_json, element.getName().mb_str(wxConvUTF8).data(), element.getValue().GetLong());
        break;

    case cJSON_String:
        cJSON_AddStringToObject(_json, element.getName().mb_str(wxConvUTF8).data(),
                                element.getValue().GetString().mb_str(wxConvUTF8).data());
        break;

    case cJSON_Array:
    case cJSON_Object:
        cJSON_AddItemToObject(_json, element.getName().mb_str(wxConvUTF8).data(), element._json);
        break;
    }
}
Ejemplo n.º 8
0
	// lua_to_json
	inline cJSON* lua_to_json(lua_State* L){
		if(lua_objlen(L, -1) > 0){
			cJSON* ele =cJSON_CreateArray();
			const int len =lua_objlen(L, -1);
			for(int i=1; i<=len; ++i){
				lua_rawgeti(L, -1, i);
				if(lua_isnil(L, -1)){
					cJSON_AddItemToArray(ele, cJSON_CreateNull());
				}
				else if(lua_isboolean(L, -1)){
					if(lua_toboolean(L, -1)){
						cJSON_AddItemToArray(ele, cJSON_CreateTrue());
					}
					else{
						cJSON_AddItemToArray(ele, cJSON_CreateFalse());
					}
				}
				else if(lua_isnumber(L, -1)){
					cJSON_AddItemToArray(ele, cJSON_CreateNumber(lua_tonumber(L, -1)));
				}
				else if(lua_isstring(L, -1)){
					cJSON_AddItemToArray(ele, cJSON_CreateString(lua_tostring(L, -1)));
				}
				else if(lua_istable(L, -1)){
					cJSON_AddItemToArray(ele, lua_to_json(L));
				}
				lua_pop(L, 1);
			}
			return ele;
		}
		else{
			cJSON* ele =cJSON_CreateObject();
			lua_pushnil(L);
			while(0 != lua_next(L, -2)){
				if(lua_isstring(L, -2)){
					const char* name =lua_tostring(L, -2);
					if(lua_isboolean(L, -1)){
						if(lua_toboolean(L, -1)){
							cJSON_AddTrueToObject(ele, name);
						}
						else{
							cJSON_AddFalseToObject(ele, name);
						}
					}
					else if(lua_isnumber(L, -1)){
						cJSON_AddNumberToObject(ele, name, lua_tonumber(L, -1));
					}
					else if(lua_isstring(L, -1)){
						cJSON_AddStringToObject(ele, name, lua_tostring(L, -1));
					}
					else if(lua_istable(L, -1)){
						cJSON_AddItemToObject(ele, name, lua_to_json(L));
					}
				}
				lua_pop(L, 1);
			}
			return ele;
		}
	}
Ejemplo n.º 9
0
	void App42Object::setObject(const char *key, bool value)
	{
		if (value)
		{
			cJSON_AddTrueToObject(jsonObject, key);
		}
		else
		{
			cJSON_AddFalseToObject(jsonObject, key);
		}
	}
Ejemplo n.º 10
0
static void cjson_add_false_should_add_false(void)
{
    cJSON *root = cJSON_CreateObject();
    cJSON *false_item = NULL;

    cJSON_AddFalseToObject(root, "false");

    TEST_ASSERT_NOT_NULL(false_item = cJSON_GetObjectItemCaseSensitive(root, "false"));
    TEST_ASSERT_EQUAL_INT(false_item->type, cJSON_False);

    cJSON_Delete(root);
}
Ejemplo n.º 11
0
static void cjson_add_false_should_fail_on_allocation_failure(void)
{
    cJSON *root = cJSON_CreateObject();

    cJSON_InitHooks(&failing_hooks);

    TEST_ASSERT_NULL(cJSON_AddFalseToObject(root, "false"));

    cJSON_InitHooks(NULL);

    cJSON_Delete(root);
}
Ejemplo n.º 12
0
Archivo: ex1.c Proyecto: mineasum/ATG
void ExampleWriteJSON(){
	cJSON *jsonroot,*fmt;
	char  *out;
	jsonroot=cJSON_CreateObject();	
	cJSON_AddItemToObject(jsonroot, "name", cJSON_CreateString("Jack (Bee) Nimble"));
	cJSON_AddItemToObject(jsonroot, "format", fmt=cJSON_CreateObject());
	cJSON_AddStringToObject(fmt,"type",		"rect");
	cJSON_AddNumberToObject(fmt,"width",		1920);
	cJSON_AddNumberToObject(fmt,"height",		1080);
	cJSON_AddFalseToObject (fmt,"interlace");
	cJSON_AddNumberToObject(fmt,"frame rate",	24);
	out=cJSON_PrintUnformatted(jsonroot);	
	Info("%s\n",out);	
	free(out);	
	cJSON_Delete(jsonroot);
}
int MSG_SetReportedState( int payload_len, char * payload, bool rep_state)
{
	//Publish the new state
	cJSON *root, *state, *reported_state;
	root = cJSON_CreateObject();
	cJSON_AddItemToObject(root, "state", state = cJSON_CreateObject() );
	cJSON_AddItemToObject(state, "reported", reported_state = cJSON_CreateObject() );

	if (rep_state)
		cJSON_AddTrueToObject(reported_state, "active");
	else
		cJSON_AddFalseToObject(reported_state, "active");

	snprintf( payload, payload_len, "%s", cJSON_Print(root) );


JSON_CLEAN:
	if(root)
		cJSON_Delete(root);

	return 0;
}
Ejemplo n.º 14
0
    void Client::joinRoomInUserRange(int minJoinedUsers, int maxJoinedUsers, bool maxPreferred)
    {
        if((_state != ConnectionState::connected) || (_socket == NULL)){
            if(_roomlistener != NULL)
			{
				room _room;
				_room.result = ResultCode::connection_error;
				_roomlistener->onJoinRoomDone(_room);
			}
            return;
        }
        int byteLen;
		byte *req;
        
		std::string payload;
		cJSON *payloadJSON;
		payloadJSON = cJSON_CreateObject();
		cJSON_AddNumberToObject(payloadJSON, "minUsers", minJoinedUsers);
		cJSON_AddNumberToObject(payloadJSON, "maxUsers", maxJoinedUsers);
        maxPreferred ? cJSON_AddTrueToObject(payloadJSON, "maxPreferred") : cJSON_AddFalseToObject(payloadJSON, "maxPreferred");
		char *cRet =  cJSON_PrintUnformatted(payloadJSON);
		payload = cRet;
        
		req = buildWarpRequest(RequestType::join_room_range, payload, byteLen);
        
		char *data = new char[byteLen];
		for(int i=0; i< byteLen; ++i)
		{
			data[i] = req[i];
		}
        
		_socket->sockSend(data, byteLen);
        
		delete[] data;
		delete[] req;
		cJSON_Delete(payloadJSON);
		free(cRet);
    }
Ejemplo n.º 15
0
void outputJsonMaterialFile(const std::string &texturefilename, const std::string &filename)
{
	cJSON *root = cJSON_CreateObject();
	cJSON *material = cJSON_CreateObject();

	cJSON *textures = cJSON_CreateArray();
	cJSON *diffuse = cJSON_CreateString((texturefilename + ".texture").c_str());
	cJSON_AddItemToArray(textures, diffuse);


	cJSON_AddItemToObject(root, "material", material);
	cJSON_AddItemToObject(material, "textures", textures);
	cJSON_AddStringToObject(material, "vshader", (outdir + "/Shaders/simple.vp").c_str());
	cJSON_AddStringToObject(material, "fshader", (outdir + "/Shaders/simple.fp").c_str());

	cJSON *state = cJSON_CreateObject();

	cJSON_AddItemToObject(material, "state", state);
	cJSON_AddFalseToObject(state, "enable-alpha-test");
	cJSON_AddStringToObject(state, "compare-alpha-test", "less-equal");
	cJSON_AddNumberToObject(state, "threshold-alpha-test", 127);

	writeJsonToFile(root, filename + ".material");
}
Ejemplo n.º 16
0
void createJsonText1()
{
    cJSON *root, *fmt;
    root = cJSON_CreateObject();
    cJSON_AddItemToObject(root, "name", cJSON_CreateString("Jack(\"Bee\")Nimble"));
    cJSON_AddItemToObject(root, "format", fmt = cJSON_CreateObject());
    cJSON_AddItemToObject(fmt, "type", cJSON_CreateString("rect"));
    cJSON_AddItemToObject(fmt, "width", cJSON_CreateNumber(1920));
    cJSON_AddNumberToObject(fmt, "height", 1080);
    cJSON_AddFalseToObject(fmt, "interface");
    cJSON_AddItemToObject(fmt, "isMan", cJSON_CreateFalse());
    char *out;
    
    out = cJSON_Print(fmt);
    printf("%s\n", out);
    free(out);
    
    out = cJSON_Print(root);
    printf("%s\n", out);
    cJSON_Delete(root);
    free(out);
    
    
}
Ejemplo n.º 17
0
void save_presets(int do_update)
{
    char * outputdata;
    int count, i;
    cJSON *root, *userobj, *versionobj, *graphicsobj;
    FILE* f;

    root = cJSON_CreateObject();

    cJSON_AddStringToObject(root, "Powder Toy Preferences", "Don't modify this file unless you know what you're doing. P.S: editing the admin/mod fields in your user info doesn't give you magical powers");

    //User Info
    if(svf_login) {
        cJSON_AddItemToObject(root, "user", userobj=cJSON_CreateObject());
        cJSON_AddStringToObject(userobj, "name", svf_user);
        cJSON_AddStringToObject(userobj, "id", svf_user_id);
        cJSON_AddStringToObject(userobj, "session_id", svf_session_id);
        if(svf_admin) {
            cJSON_AddTrueToObject(userobj, "admin");
            cJSON_AddFalseToObject(userobj, "mod");
        } else if(svf_mod) {
            cJSON_AddFalseToObject(userobj, "admin");
            cJSON_AddTrueToObject(userobj, "mod");
        } else {
            cJSON_AddFalseToObject(userobj, "admin");
            cJSON_AddFalseToObject(userobj, "mod");
        }
    }

    //Version Info
    cJSON_AddItemToObject(root, "version", versionobj=cJSON_CreateObject());
    cJSON_AddNumberToObject(versionobj, "major", SAVE_VERSION);
    cJSON_AddNumberToObject(versionobj, "minor", MINOR_VERSION);
    cJSON_AddNumberToObject(versionobj, "build", BUILD_NUM);
    if(do_update) {
        cJSON_AddTrueToObject(versionobj, "update");
    } else {
        cJSON_AddFalseToObject(versionobj, "update");
    }

    //Display settings
    cJSON_AddItemToObject(root, "graphics", graphicsobj=cJSON_CreateObject());
    cJSON_AddNumberToObject(graphicsobj, "colour", colour_mode);
    count = 0;
    i = 0;
    while(display_modes[i++]) {
        count++;
    }
    cJSON_AddItemToObject(graphicsobj, "display", cJSON_CreateIntArray(display_modes, count));
    count = 0;
    i = 0;
    while(render_modes[i++]) {
        count++;
    }
    cJSON_AddItemToObject(graphicsobj, "render", cJSON_CreateIntArray(render_modes, count));

    //General settings
    cJSON_AddStringToObject(root, "proxy", http_proxy_string);
    cJSON_AddNumberToObject(root, "scale", sdl_scale);

    outputdata = cJSON_Print(root);
    cJSON_Delete(root);

    f = fopen("powder.pref", "wb");
    if(!f)
        return;
    fwrite(outputdata, 1, strlen(outputdata), f);
    fclose(f);
    free(outputdata);
    //Old format, here for reference only
    /*FILE *f=fopen("powder.def", "wb");
    unsigned char sig[4] = {0x50, 0x44, 0x65, 0x68};
    unsigned char tmp = sdl_scale;
    if (!f)
    	return;
    fwrite(sig, 1, 4, f);
    save_string(f, svf_user);
    //save_string(f, svf_pass);
    save_string(f, svf_user_id);
    save_string(f, svf_session_id);
    fwrite(&tmp, 1, 1, f);
    tmp = cmode;
    fwrite(&tmp, 1, 1, f);
    tmp = svf_admin;
    fwrite(&tmp, 1, 1, f);
    tmp = svf_mod;
    fwrite(&tmp, 1, 1, f);
    save_string(f, http_proxy_string);
    tmp = SAVE_VERSION;
    fwrite(&tmp, 1, 1, f);
    tmp = MINOR_VERSION;
    fwrite(&tmp, 1, 1, f);
    tmp = BUILD_NUM;
    fwrite(&tmp, 1, 1, f);
    tmp = do_update;
    fwrite(&tmp, 1, 1, f);
    fclose(f);*/
}
Ejemplo n.º 18
0
void save_presets(int do_update)
{
	//*/
	int i, count;
	char * outputdata;
	cJSON *root, *userobj, *versionobj, *recobj, *graphicsobj, *hudobj;
	FILE *f = fopen("powder.pref", "wb");
	if(!f)
		return;
	root = cJSON_CreateObject();
	
	cJSON_AddStringToObject(root, "Powder Toy Preferences", "Don't modify this file unless you know what you're doing. P.S: editing the admin/mod fields in your user info doesn't give you magical powers");
	
	//User Info
	if(svf_login){
		cJSON_AddItemToObject(root, "user", userobj=cJSON_CreateObject());
		cJSON_AddStringToObject(userobj, "name", svf_user);
		cJSON_AddStringToObject(userobj, "id", svf_user_id);
		cJSON_AddStringToObject(userobj, "session_id", svf_session_id);
		if(svf_admin){
			cJSON_AddTrueToObject(userobj, "admin");
			cJSON_AddFalseToObject(userobj, "mod");
		} else if(svf_mod){
			cJSON_AddFalseToObject(userobj, "admin");
			cJSON_AddTrueToObject(userobj, "mod");
		} else {
			cJSON_AddFalseToObject(userobj, "admin");
			cJSON_AddFalseToObject(userobj, "mod");
		}
	}
	
	//Version Info
	cJSON_AddItemToObject(root, "version", versionobj=cJSON_CreateObject());
	cJSON_AddNumberToObject(versionobj, "major", SAVE_VERSION);
	cJSON_AddNumberToObject(versionobj, "minor", MINOR_VERSION);
	cJSON_AddNumberToObject(versionobj, "build", BUILD_NUM);
	if(do_update){
		cJSON_AddTrueToObject(versionobj, "update");
	} else {
		cJSON_AddFalseToObject(versionobj, "update");
	}
	
	//Fav Menu/Records
	cJSON_AddItemToObject(root, "records", recobj=cJSON_CreateObject());
	cJSON_AddNumberToObject(recobj, "num elements in menu", locked);
	for (i = 0; i < locked; i++)
	{
		char eltext[128] = "";
		sprintf(eltext,"element %i",i);
		cJSON_AddNumberToObject(recobj, eltext, favMenu[18-i]);
	}
	cJSON_AddNumberToObject(recobj, "Alternate HUD ON", alt_hud);
	cJSON_AddNumberToObject(recobj, "Total Time Played", ((double)currentTime/1000)+((double)totaltime/1000)-((double)totalafktime/1000)-((double)afktime/1000));
	cJSON_AddNumberToObject(recobj, "Average FPS", totalfps/frames);
	cJSON_AddNumberToObject(recobj, "Number of frames", frames);
	cJSON_AddNumberToObject(recobj, "Max FPS", maxfps);
	cJSON_AddNumberToObject(recobj, "Total AFK Time", ((double)totalafktime/1000)+((double)afktime/1000)+((double)prevafktime/1000));
	cJSON_AddNumberToObject(recobj, "Times Played", timesplayed);

	//Display settings
	cJSON_AddItemToObject(root, "graphics", graphicsobj=cJSON_CreateObject());
	cJSON_AddNumberToObject(graphicsobj, "colour", colour_mode);
	count = 0; i = 0; while(display_modes[i++]){ count++; }
	cJSON_AddItemToObject(graphicsobj, "display", cJSON_CreateIntArray(display_modes, count));
	count = 0; i = 0; while(render_modes[i++]){ count++; }
	cJSON_AddItemToObject(graphicsobj, "render", cJSON_CreateIntArray(render_modes, count));
	
	//HUDs
	cJSON_AddItemToObject(root, "HUD", hudobj=cJSON_CreateObject());
	cJSON_AddItemToObject(hudobj, "normal", cJSON_CreateIntArray(hud_normal, HUD_OPTIONS));
	cJSON_AddItemToObject(hudobj, "debug", cJSON_CreateIntArray(hud_debug, HUD_OPTIONS));
	cJSON_AddItemToObject(hudobj, "modnormal", cJSON_CreateIntArray(hud_modnormal, HUD_OPTIONS));
	cJSON_AddItemToObject(hudobj, "moddebug", cJSON_CreateIntArray(hud_moddebug, HUD_OPTIONS));

	//General settings
	cJSON_AddStringToObject(root, "proxy", http_proxy_string);
	cJSON_AddNumberToObject(root, "scale", sdl_scale);
	cJSON_AddNumberToObject(root, "Debug mode", DEBUG_MODE);
	
	outputdata = cJSON_Print(root);
	cJSON_Delete(root);
	
	fwrite(outputdata, 1, strlen(outputdata), f);
	fclose(f);
	free(outputdata);
	//Old format, here for reference only
	/*/FILE *f=fopen("powder.def", "wb");
	unsigned char sig[4] = {0x50, 0x44, 0x65, 0x68};
	unsigned char tmp = sdl_scale;
	if (!f)
		return;
	fwrite(sig, 1, 4, f);
	save_string(f, svf_user);
	//save_string(f, svf_pass);
	save_string(f, svf_user_id);
	save_string(f, svf_session_id);
	fwrite(&tmp, 1, 1, f);
	tmp = cmode;
	fwrite(&tmp, 1, 1, f);
	tmp = svf_admin;
	fwrite(&tmp, 1, 1, f);
	tmp = svf_mod;
	fwrite(&tmp, 1, 1, f);
	save_string(f, http_proxy_string);
	tmp = SAVE_VERSION;
	fwrite(&tmp, 1, 1, f);
	tmp = MINOR_VERSION;
	fwrite(&tmp, 1, 1, f);
	tmp = BUILD_NUM;
	fwrite(&tmp, 1, 1, f);
	tmp = do_update;
	fwrite(&tmp, 1, 1, f);
	fclose(f);
	/*/
}
Ejemplo n.º 19
-1
/* Create a bunch of objects as demonstration. */
void create_objects()
{
    cJSON *root, *fmt, *img, *thm, *fld; char *out; int i;	/* declare a few. */
                                                            /* Our "days of the week" array: */
    const char *strings[7] = { "Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday" };
    /* Our matrix: */
    int numbers[3][3] = { { 0,-1,0 },{ 1,0,0 },{ 0,0,1 } };
    /* Our "gallery" item: */
    int ids[4] = { 116,943,234,38793 };
    /* Our array of "records": */
    struct record fields[2] = {
        { "zip",37.7668,-1.223959e+2,"","SAN FRANCISCO","CA","94107","US" },
        { "zip",37.371991,-1.22026e+2,"","SUNNYVALE","CA","94085","US" } };

    /* Here we construct some JSON standards, from the JSON site. */

    /* Our "Video" datatype: */
    root = cJSON_CreateObject();
    cJSON_AddItemToObject(root, "name", cJSON_CreateString("Jack (\"Bee\") Nimble"));
    cJSON_AddItemToObject(root, "format", fmt = cJSON_CreateObject());
    cJSON_AddStringToObject(fmt, "type", "rect");
    cJSON_AddNumberToObject(fmt, "width", 1920);
    cJSON_AddNumberToObject(fmt, "height", 1080);
    cJSON_AddFalseToObject(fmt, "interlace");
    cJSON_AddNumberToObject(fmt, "frame rate", 24);

    out = cJSON_Print(root);	cJSON_Delete(root);	printf("%s\n", out);	free(out);	/* Print to text, Delete the cJSON, print it, release the string. */

                                                                                        /* Our "days of the week" array: */
    root = cJSON_CreateStringArray(strings, 7);

    out = cJSON_Print(root);	cJSON_Delete(root);	printf("%s\n", out);	free(out);

    /* Our matrix: */
    root = cJSON_CreateArray();
    for (i = 0; i<3; i++) cJSON_AddItemToArray(root, cJSON_CreateIntArray(numbers[i], 3));

    /*	cJSON_ReplaceItemInArray(root,1,cJSON_CreateString("Replacement")); */

    out = cJSON_Print(root);	cJSON_Delete(root);	printf("%s\n", out);	free(out);


    /* Our "gallery" item: */
    root = cJSON_CreateObject();
    cJSON_AddItemToObject(root, "Image", img = cJSON_CreateObject());
    cJSON_AddNumberToObject(img, "Width", 800);
    cJSON_AddNumberToObject(img, "Height", 600);
    cJSON_AddStringToObject(img, "Title", "View from 15th Floor");
    cJSON_AddItemToObject(img, "Thumbnail", thm = cJSON_CreateObject());
    cJSON_AddStringToObject(thm, "Url", "http:/*www.example.com/image/481989943");
    cJSON_AddNumberToObject(thm, "Height", 125);
    cJSON_AddStringToObject(thm, "Width", "100");
    cJSON_AddItemToObject(img, "IDs", cJSON_CreateIntArray(ids, 4));

    out = cJSON_Print(root);	cJSON_Delete(root);	printf("%s\n", out);	free(out);

    /* Our array of "records": */

    root = cJSON_CreateArray();
    for (i = 0; i<2; i++)
    {
        cJSON_AddItemToArray(root, fld = cJSON_CreateObject());
        cJSON_AddStringToObject(fld, "precision", fields[i].precision);
        cJSON_AddNumberToObject(fld, "Latitude", fields[i].lat);
        cJSON_AddNumberToObject(fld, "Longitude", fields[i].lon);
        cJSON_AddStringToObject(fld, "Address", fields[i].address);
        cJSON_AddStringToObject(fld, "City", fields[i].city);
        cJSON_AddStringToObject(fld, "State", fields[i].state);
        cJSON_AddStringToObject(fld, "Zip", fields[i].zip);
        cJSON_AddStringToObject(fld, "Country", fields[i].country);
    }

    /*	cJSON_ReplaceItemInObject(cJSON_GetArrayItem(root,1),"City",cJSON_CreateIntArray(ids,4)); */

    out = cJSON_Print(root);	cJSON_Delete(root);	printf("%s\n", out);	free(out);

}