本文整理汇总了C++中JsonParse函数的典型用法代码示例。如果您正苦于以下问题:C++ JsonParse函数的具体用法?C++ JsonParse怎么用?C++ JsonParse使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了JsonParse函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_parse_array_bad_nested_elems
static void test_parse_array_bad_nested_elems(void)
{
{
const char *data = "[ \"foo\" [\"baz\"], \"bar\" ]";
JsonElement *json = NULL;
assert_int_not_equal(JSON_PARSE_OK, JsonParse(&data, &json));
assert_false(json);
}
{
const char *data = "[\"foo\"[\"baz\"],\"bar\"]";
JsonElement *json = NULL;
assert_int_not_equal(JSON_PARSE_OK, JsonParse(&data, &json));
assert_false(json);
}
{
const char *data = "[ \"foo\" {\"boing\": \"baz\"}, \"bar\" ]";
JsonElement *json = NULL;
assert_int_not_equal(JSON_PARSE_OK, JsonParse(&data, &json));
assert_false(json);
}
{
const char *data = "[\"foo\"{\"boing\":\"baz\"},\"bar\"]";
JsonElement *json = NULL;
assert_int_not_equal(JSON_PARSE_OK, JsonParse(&data, &json));
assert_false(json);
}
}
示例2: test_parse_object_garbage
static void test_parse_object_garbage(void)
{
{
const char *data = "{ \"first\": 1, garbage \"second\": 2 }";
JsonElement *json = NULL;
assert_int_not_equal(JSON_PARSE_OK, JsonParse(&data, &json));
assert_false(json);
}
{
const char *data = "{ \"first\": 1 garbage \"second\": 2 }";
JsonElement *json = NULL;
assert_int_not_equal(JSON_PARSE_OK, JsonParse(&data, &json));
assert_false(json);
}
{
const char *data = "{ \"first\": garbage, \"second\": 2 }";
JsonElement *json = NULL;
assert_int_not_equal(JSON_PARSE_OK, JsonParse(&data, &json));
assert_false(json);
}
{
const char *data = "{ \"first\": garbage \"second\": 2 }";
JsonElement *json = NULL;
assert_int_not_equal(JSON_PARSE_OK, JsonParse(&data, &json));
assert_false(json);
}
}
示例3: test_parse_array_garbage
static void test_parse_array_garbage(void **state)
{
{
const char *data = "[1, garbage]";
JsonElement *json = JsonParse(&data);
assert_false(json);
}
{
const char *data = "[1 garbage]";
JsonElement *json = JsonParse(&data);
assert_false(json);
}
{
const char *data = "[garbage]";
JsonElement *json = JsonParse(&data);
assert_false(json);
}
{
const char *data = "[garbage, 1]";
JsonElement *json = JsonParse(&data);
assert_false(json);
}
}
示例4: test_parse_array_garbage
static void test_parse_array_garbage(void)
{
{
const char *data = "[1, garbage]";
JsonElement *json = NULL;
assert_int_not_equal(JSON_PARSE_OK, JsonParse(&data, &json));
assert_false(json);
}
{
const char *data = "[1 garbage]";
JsonElement *json = NULL;
assert_int_not_equal(JSON_PARSE_OK, JsonParse(&data, &json));
assert_false(json);
}
{
const char *data = "[garbage]";
JsonElement *json = NULL;
assert_int_not_equal(JSON_PARSE_OK, JsonParse(&data, &json));
assert_false(json);
}
{
const char *data = "[garbage, 1]";
JsonElement *json = NULL;
assert_int_not_equal(JSON_PARSE_OK, JsonParse(&data, &json));
assert_false(json);
}
}
示例5: test_parse_object_garbage
static void test_parse_object_garbage(void **state)
{
{
const char *data = "{ \"first\": 1, garbage \"second\": 2 }";
JsonElement *json = JsonParse(&data);
assert_false(json);
}
{
const char *data = "{ \"first\": 1 garbage \"second\": 2 }";
JsonElement *json = JsonParse(&data);
assert_false(json);
}
{
const char *data = "{ \"first\": garbage, \"second\": 2 }";
JsonElement *json = JsonParse(&data);
assert_false(json);
}
{
const char *data = "{ \"first\": garbage \"second\": 2 }";
JsonElement *json = JsonParse(&data);
assert_false(json);
}
}
示例6: test_parse_array_nested_garbage
static void test_parse_array_nested_garbage(void **state)
{
{
const char *data = "[1, [garbage]]";
JsonElement *json = JsonParse(&data);
assert_false(json);
}
{
const char *data = "[1, { garbage }]";
JsonElement *json = JsonParse(&data);
assert_false(json);
}
}
示例7: test_parse_object_nested_garbage
static void test_parse_object_nested_garbage(void **state)
{
{
const char *data = "{ \"first\": { garbage } }";
JsonElement *json = JsonParse(&data);
assert_false(json);
}
{
const char *data = "{ \"first\": [ garbage ] }";
JsonElement *json = JsonParse(&data);
assert_false(json);
}
}
示例8: test_parse_empty_string
static void test_parse_empty_string(void)
{
const char *data = "";
JsonElement *json = NULL;
assert_int_not_equal(JSON_PARSE_OK, JsonParse(&data, &json));
assert_false(json);
data = "\"\"";
assert_int_equal(JSON_PARSE_OK, JsonParse(&data, &json));
assert_string_equal("", JsonPrimitiveGetAsString(json));
JsonDestroy(json);
}
示例9: test_parse_escaped_string
static void test_parse_escaped_string(void)
{
{
const char *data = "\"\\\\\"";
const char *original = data;
JsonElement *json = NULL;
assert_int_equal(JSON_PARSE_OK, JsonParse(&data, &json));
assert_string_equal("\\", JsonPrimitiveGetAsString(json));
char *out = JsonToString(json);
assert_string_equal(original, out);
free(out);
JsonDestroy(json);
}
{
// included by paranoia from Redmine #5773
const char *data = "\"/\\\\//\\\\/\\\\\"";
const char *original = data;
JsonElement *json = NULL;
assert_int_equal(JSON_PARSE_OK, JsonParse(&data, &json));
assert_string_equal("/\\//\\/\\", JsonPrimitiveGetAsString(json));
char *out = JsonToString(json);
assert_string_equal(original, out);
free(out);
JsonDestroy(json);
}
{
const char *data = "\"x\\tx\"";
const char *original = data;
JsonElement *json = NULL;
assert_int_equal(JSON_PARSE_OK, JsonParse(&data, &json));
assert_string_equal("x\tx", JsonPrimitiveGetAsString(json));
char *out = JsonToString(json);
assert_string_equal(original, out);
free(out);
JsonDestroy(json);
}
}
示例10: test_parse_bad_apple2
static void test_parse_bad_apple2(void **state)
{
const char *data = "][";
JsonElement *json = JsonParse(&data);
assert_false(json);
}
示例11: test_parse_array_diverse
static void test_parse_array_diverse(void **state)
{
{
const char *data = "[1, \"snookie\", 1.0, {}, [], true, false, null ]";
JsonElement *json = JsonParse(&data);
assert_true(json);
JsonElementDestroy(json);
}
{
const char *data = "[1,\"snookie\",1.0,{},[],true,false,null]";
JsonElement *json = JsonParse(&data);
assert_true(json);
JsonElementDestroy(json);
}
}
示例12: test_parse_empty
static void test_parse_empty(void **state)
{
const char *data = "";
JsonElement *json = JsonParse(&data);
assert_false(json);
}
示例13: test_parse_object_diverse
static void test_parse_object_diverse(void **state)
{
{
const char *data = "{ \"a\": 1, \"b\": \"snookie\", \"c\": 1.0, \"d\": {}, \"e\": [], \"f\": true, \"g\": false, \"h\": null }";
JsonElement *json = JsonParse(&data);
assert_true(json);
JsonElementDestroy(json);
}
{
const char *data = "{\"a\":1,\"b\":\"snookie\",\"c\":1.0,\"d\":{},\"e\":[],\"f\":true,\"g\":false,\"h\":null}";
JsonElement *json = JsonParse(&data);
assert_true(json);
JsonElementDestroy(json);
}
}
示例14: test_parse_object_double_colon
static void test_parse_object_double_colon(void)
{
{
const char *data = "{ \"foo\":: \"bar\" }";
JsonElement *json = NULL;
assert_int_not_equal(JSON_PARSE_OK, JsonParse(&data, &json));
assert_false(json);
}
{
const char *data = "{\"foo\"::\"bar\"}";
JsonElement *json = NULL;
assert_int_not_equal(JSON_PARSE_OK, JsonParse(&data, &json));
assert_false(json);
}
}
示例15: test_parse_object_nested_garbage
static void test_parse_object_nested_garbage(void)
{
{
const char *data = "{ \"first\": { garbage } }";
JsonElement *json = NULL;
assert_int_not_equal(JSON_PARSE_OK, JsonParse(&data, &json));
assert_false(json);
}
{
const char *data = "{ \"first\": [ garbage ] }";
JsonElement *json = NULL;
assert_int_not_equal(JSON_PARSE_OK, JsonParse(&data, &json));
assert_false(json);
}
}