Ejemplo n.º 1
0
static const char *GetJsonText(KonohaContext *kctx, struct JsonBuf *jsonbuf, const char *key, size_t keylen_or_zero, const char *defval)
{
	if(key == NULL)
		JSONString_get(toJSON(jsonbuf->json_i));
	size_t length = KeyLen(key, keylen_or_zero);
	return JSON_getString(toJSON(jsonbuf->json_i), key, &length);
}
Ejemplo n.º 2
0
static double GetJsonFloat(KonohaContext *kctx, struct JsonBuf *jsonbuf, const char *key, size_t keylen_or_zero, double defval)
{
	JSON json = AsJSON(jsonbuf);
	if(key == NULL)
		return JSONDouble_get(json);
	return JSON_getDouble(json, key, KeyLen(key, keylen_or_zero));
}
Ejemplo n.º 3
0
static kbool_t GetJsonBoolean(KonohaContext *kctx, struct JsonBuf *jsonbuf, const char *key, size_t keylen_or_zero, kbool_t defval)
{
	JSON json = AsJSON(jsonbuf);
	if(key == NULL)
		return JSONBool_get(json);
	return JSON_getBool(json, key, KeyLen(key, keylen_or_zero));
}
Ejemplo n.º 4
0
static kbool_t RetrieveJsonKeyValue(KonohaContext *kctx, struct JsonBuf *jsonbuf, const char *key, size_t keylen_or_zero, struct JsonBuf *newbuf)
{
	JSON json = JSON_get(AsJSON(jsonbuf), key, KeyLen(key, keylen_or_zero));
	JSONObject_Retain(json);
	newbuf->json_i = json.bits;
	return newbuf->json_i != 0;
}
Ejemplo n.º 5
0
static int64_t GetJsonInt(KonohaContext *kctx, struct JsonBuf *jsonbuf, const char *key, size_t keylen_or_zero, int64_t defval)
{
	if(key == NULL) {
		if(JSON_TYPE_CHECK(Int32, toJSON(jsonbuf->json_i))) {
			return JSONInt_get(toJSON(jsonbuf->json_i));
		}
	}
	return JSON_getInt(toJSON(jsonbuf->json_i), key, KeyLen(key, keylen_or_zero));
}
Ejemplo n.º 6
0
static const char *GetJsonText(KonohaContext *kctx, struct JsonBuf *jsonbuf, const char *key, size_t keylen_or_zero, const char *defval)
{
	size_t length;
	JSON json = AsJSON(jsonbuf);
	if(key == NULL)
		return JSONString_get(json);
	length = KeyLen(key, keylen_or_zero);
	return JSON_getString(json, key, &length);
}
Ejemplo n.º 7
0
static kbool_t SetJsonKeyValue(KonohaContext *kctx, struct JsonBuf *jsonbuf, const char *key, size_t keylen_or_zero, struct JsonBuf *otherbuf)
{
	if(!JSON_TYPE_CHECK(Object, toJSON(jsonbuf->json_i))) {
		return false;
	}
	size_t keylen = KeyLen(key, keylen_or_zero);
	JSONObject_set((JSONMemoryPool *)(PLATAPI JsonHandler), toJSON(jsonbuf->json_i),
			key, keylen, toJSON(otherbuf->json_i));
	return true;
}
Ejemplo n.º 8
0
static kbool_t SetJsonKeyValue(KonohaContext *kctx, struct JsonBuf *jsonbuf, const char *key, size_t keylen_or_zero, struct JsonBuf *otherbuf)
{
	JSON json = AsJSON(jsonbuf);
	size_t keylen;
	if(!JSON_TYPE_CHECK(Object, json)) {
		return false;
	}
	keylen = KeyLen(key, keylen_or_zero);
	JSONObject_set((JSONMemoryPool *)(JSONAPI JsonHandler), json, key, keylen, AsJSON(otherbuf));
	return true;
}
Ejemplo n.º 9
0
static int64_t GetJsonInt(KonohaContext *kctx, struct JsonBuf *jsonbuf, const char *key, size_t keylen_or_zero, int64_t defval)
{
	JSON json = AsJSON(jsonbuf);
	if(key == NULL) {
		if(JSON_TYPE_CHECK(Int32, json)) {
			return JSONInt_get(json);
		} else if(JSON_TYPE_CHECK(Int64, json)) {
			return JSONInt64_get(json);
		} else {
			return 0;
		}
	}
	return JSON_getInt(json, key, KeyLen(key, keylen_or_zero));
}
Ejemplo n.º 10
0
static kbool_t SetJsonValue(KonohaContext *kctx, struct JsonBuf *jsonbuf, const char *key, size_t keylen_or_zero, KJSONTYPE type, ...)
{
	va_list ap;
	va_start(ap, type);
	JSON val = toJSON(NewJsonI((JSONMemoryPool *)(PLATAPI JsonHandler), type, ap));
	kbool_t ret = true;
	if(key != NULL) {
		size_t keylen = KeyLen(key, keylen_or_zero);
		JSONObject_set((JSONMemoryPool *)(PLATAPI JsonHandler),
				toJSON(jsonbuf->json_i), key, keylen, val);
	}
	else {
		jsonbuf->json_i = val.bits;
	}
	va_end(ap);
	return ret;
}
Ejemplo n.º 11
0
static double GetJsonFloat(KonohaContext *kctx, struct JsonBuf *jsonbuf, const char *key, size_t keylen_or_zero, double defval)
{
	if(key == NULL)
		JSONDouble_get(toJSON(jsonbuf->json_i));
	return JSON_getDouble(toJSON(jsonbuf->json_i), key, KeyLen(key, keylen_or_zero));
}
Ejemplo n.º 12
0
static kbool_t RetrieveJsonKeyValue(KonohaContext *kctx, struct JsonBuf *jsonbuf, const char *key, size_t keylen_or_zero, struct JsonBuf *newbuf)
{
	newbuf->json_i = JSON_get(toJSON(jsonbuf->json_i), key, KeyLen(key, keylen_or_zero)).bits;
	return newbuf->json_i != 0;
}