コード例 #1
0
ファイル: group.cpp プロジェクト: drahosj/308labs
json_value* Group::ToJson()
{
	json_value * array = json_array_new(0);
	json_array_push(array, json_string_new(this->name.c_str()));
	for(std::vector<Json*>::iterator it = this->children.begin(); it != this->children.end(); ++it)
	{
		json_array_push(array, (*it)->ToJson());
	}
	return array;
}
コード例 #2
0
ファイル: opensensordata.c プロジェクト: baltoche/p2pfoodlab
void osd_group_add_photostream(json_object_t g, int id)
{
        json_object_t a = json_object_get(g, "photostreams");
        json_object_t d = json_object_create();
        json_object_setnum(d, "id", id);
        json_array_push(a, d);
        json_unref(d);
}
コード例 #3
0
ファイル: gsub-reverse.c プロジェクト: anthrotype/otfcc
json_value *otl_gsub_dump_reverse(const otl_Subtable *_subtable) {
	const subtable_gsub_reverse *subtable = &(_subtable->gsub_reverse);
	json_value *_st = json_object_new(3);
	json_value *_match = json_array_new(subtable->matchCount);
	for (tableid_t j = 0; j < subtable->matchCount; j++) {
		json_array_push(_match, Coverage.dump(subtable->match[j]));
	}
	json_object_push(_st, "match", _match);
	json_object_push(_st, "to", Coverage.dump(subtable->to));
	json_object_push(_st, "inputIndex", json_integer_new(subtable->inputIndex));
	return _st;
}
コード例 #4
0
json_value *caryll_gpos_mark_to_ligature_to_json(otl_subtable *st) {
	subtable_gpos_mark_to_ligature *subtable = &(st->gpos_mark_to_ligature);
	json_value *_subtable = json_object_new(3);
	json_value *_marks = json_object_new(subtable->marks->numGlyphs);
	json_value *_bases = json_object_new(subtable->bases->numGlyphs);
	for (uint16_t j = 0; j < subtable->marks->numGlyphs; j++) {
		json_value *_mark = json_object_new(3);
		sds markClassName =
		    sdscatfmt(sdsempty(), "ac_%i", subtable->markArray->records[j].markClass);
		json_object_push(_mark, "class",
		                 json_string_new_length((uint32_t)sdslen(markClassName), markClassName));
		sdsfree(markClassName);
		json_object_push(_mark, "x", json_integer_new(subtable->markArray->records[j].anchor.x));
		json_object_push(_mark, "y", json_integer_new(subtable->markArray->records[j].anchor.y));
		json_object_push(_marks, subtable->marks->glyphs[j].name, preserialize(_mark));
	}
	for (uint16_t j = 0; j < subtable->bases->numGlyphs; j++) {
		mark_to_ligature_base *base = subtable->ligArray[j];
		json_value *_base = json_array_new(base->componentCount);
		for (uint16_t k = 0; k < base->componentCount; k++) {
			json_value *_bk = json_object_new(subtable->classCount);
			for (uint16_t m = 0; m < subtable->classCount; m++) {
				if (base->anchors[k][m].present) {
					json_value *_anchor = json_object_new(2);
					json_object_push(_anchor, "x", json_integer_new(base->anchors[k][m].x));
					json_object_push(_anchor, "y", json_integer_new(base->anchors[k][m].y));
					sds markClassName = sdscatfmt(sdsempty(), "ac_%i", m);
					json_object_push_length(_bk, (uint32_t)sdslen(markClassName), markClassName,
					                        _anchor);
					sdsfree(markClassName);
				}
			}
			json_array_push(_base, _bk);
		}
		json_object_push(_bases, subtable->bases->glyphs[j].name, preserialize(_base));
	}
	json_object_push(_subtable, "classCount", json_integer_new(subtable->classCount));
	json_object_push(_subtable, "marks", _marks);
	json_object_push(_subtable, "bases", _bases);
	return _subtable;
}
コード例 #5
0
//exit funtion
void saveData() {
	
	printf("Saving data @ %d...\n", currentMatchId);

	//make new arrays to hold the data
	json_value *outputArray = json_array_new(0);
	json_value **structures = malloc(1024);

	//TODO: Save brawler data into BRAWLER_DATA_FILE
	json_value *outputBrawlerArray = json_array_new(0);
	json_value *(brawlerStructs[4]);

	//for every champion that may or may not have had data stored for
	for (int i = 0; i < 1024; i++) {
		//if this champion had any data stored for it (at least one brawler has been bought on this champ)
		if (outputData[i].razorfinsBought    +
			outputData[i].ironbacksBought    +
			outputData[i].plundercrabsBought +
			outputData[i].ocklepodsBought > 0) {

			//make it a new array
			structures[i] = json_array_new(11);

			//push the appropriate data into it
			json_array_push(structures[i], json_integer_new(i));
			json_array_push(structures[i], json_integer_new(outputData[i].razorfinsBought));
			json_array_push(structures[i], json_integer_new(outputData[i].ironbacksBought));
			json_array_push(structures[i], json_integer_new(outputData[i].plundercrabsBought));
			json_array_push(structures[i], json_integer_new(outputData[i].ocklepodsBought));

			json_array_push(structures[i], json_integer_new(outputData[i].offensiveBuilds));
			json_array_push(structures[i], json_integer_new(outputData[i].defensiveBuilds));

			json_array_push(structures[i], json_integer_new(outputData[i].totalDamageTaken));
			json_array_push(structures[i], json_integer_new(outputData[i].totalDamageDealt));

			json_array_push(structures[i], json_integer_new(outputData[i].wins));
			json_array_push(structures[i], json_integer_new(outputData[i].picks));

			//add it to the output array
			json_array_push(outputArray, structures[i]);
		}
	}
	
	//for every brawler
	for (int i = 0; i < 4; i++) {
		//make it a new array
		brawlerStructs[i] = json_array_new(6);

		//push the appropriate data into it
		json_array_push(brawlerStructs[i], json_integer_new(outputBrawlerData[i].offensiveBuilds));
		json_array_push(brawlerStructs[i], json_integer_new(outputBrawlerData[i].defensiveBuilds));

		json_array_push(brawlerStructs[i], json_integer_new(outputBrawlerData[i].totalDamageTakenByBuyers));
		json_array_push(brawlerStructs[i], json_integer_new(outputBrawlerData[i].totalDamageDealtByBuyers));

		json_array_push(brawlerStructs[i], json_integer_new(outputBrawlerData[i].wins));
		json_array_push(brawlerStructs[i], json_integer_new(outputBrawlerData[i].picks));

		json_value *boughtObject = json_object_new(0);

		for (int j = 0; j < 8192; j++) {
			if (outputBrawlerData[i].itemsBought[j] < 1) continue;
			char itemName[63];
			snprintf(itemName, 62, "%d", j);

			json_object_push(boughtObject, itemName, json_integer_new(outputBrawlerData[i].itemsBought[j]));
		}

		json_array_push(brawlerStructs[i], boughtObject);

		//add it to the output array
		json_array_push(outputBrawlerArray, brawlerStructs[i]);
	}

	json_serialize_opts opts;
	opts.mode = json_serialize_mode_packed;

	int length = json_measure_ex(outputArray, opts);
	char *outputJSONString = malloc(length);

	json_serialize_ex(outputJSONString, outputArray, opts);

	fwrite(outputJSONString, sizeof(char), length, outputDataFileStream);


	length = json_measure_ex(outputBrawlerArray, opts);
	char *outputJSONString_brawlers = malloc(length);

	json_serialize_ex(outputJSONString_brawlers, outputBrawlerArray, opts);

	fwrite(outputJSONString_brawlers, sizeof(char), length, outputBrawlerDataFileStream);

	fcloseall();

	//json_builder_free(outputArray);
	//json_builder_free(outputBrawlerArray);
	json_value_free(matchIdArray);
	return;
}