//## void JSON.set(String key, JSON value); static KMETHOD kJSON_set(KonohaContext *kctx, KonohaStack *sfp) { kString *s = sfp[1].asString; JSON obj, key, val; obj = ((kJSON *)sfp[0].asObject)->json; val = ((kJSON *)sfp[2].asObject)->json; key = JSONString_new(S_text(s), S_size(s)); JSONObject_set(obj, key, val); KReturnVoid(); }
static uint64_t NewJsonI(JSONMemoryPool *pool, KJSONTYPE type, va_list ap) { switch(type) { case KJSON_OBJECT: return JSONObject_new(pool, 0).bits; case KJSON_ARRAY: return JSONArray_new(pool, 0).bits; case KJSON_STRING: { const char *s = va_arg(ap, const char*); return JSONString_new(pool, s, strlen(s)).bits; } case KJSON_INT: return JSONInt_new(pool, va_arg(ap, int)).bits; case KJSON_DOUBLE: return JSONDouble_new(va_arg(ap, double)).bits; case KJSON_BOOLEAN: return JSONBool_new(va_arg(ap, int)).bits; case KJSON_NULL: return JSONNull_new().bits; case KJSON_INT64: return JSONInt_new(pool, va_arg(ap, int64_t)).bits; case KJSON_LONG: return JSONInt_new(pool, va_arg(ap, long)).bits; } return 0; }