当前位置: 首页>>代码示例>>C++>>正文


C++ JsonParse函数代码示例

本文整理汇总了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);
    }
}
开发者ID:GregorioDiStefano,项目名称:core,代码行数:30,代码来源:json_test.c

示例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);
    }
}
开发者ID:ajlill,项目名称:core,代码行数:30,代码来源:json_test.c

示例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);
    }
}
开发者ID:pombredanne,项目名称:core,代码行数:26,代码来源:json_test.c

示例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);
    }
}
开发者ID:ajlill,项目名称:core,代码行数:30,代码来源:json_test.c

示例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);
    }
}
开发者ID:pombredanne,项目名称:core,代码行数:26,代码来源:json_test.c

示例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);
    }
}
开发者ID:pombredanne,项目名称:core,代码行数:14,代码来源:json_test.c

示例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);
    }
}
开发者ID:pombredanne,项目名称:core,代码行数:14,代码来源:json_test.c

示例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);
}
开发者ID:GregorioDiStefano,项目名称:core,代码行数:15,代码来源:json_test.c

示例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);
    }
}
开发者ID:GregorioDiStefano,项目名称:core,代码行数:48,代码来源:json_test.c

示例10: test_parse_bad_apple2

static void test_parse_bad_apple2(void **state)
{
    const char *data = "][";
    JsonElement *json = JsonParse(&data);

    assert_false(json);
}
开发者ID:pombredanne,项目名称:core,代码行数:7,代码来源:json_test.c

示例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);
    }
}
开发者ID:pombredanne,项目名称:core,代码行数:16,代码来源:json_test.c

示例12: test_parse_empty

static void test_parse_empty(void **state)
{
    const char *data = "";
    JsonElement *json = JsonParse(&data);

    assert_false(json);
}
开发者ID:pombredanne,项目名称:core,代码行数:7,代码来源:json_test.c

示例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);
    }
}
开发者ID:pombredanne,项目名称:core,代码行数:16,代码来源:json_test.c

示例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);
    }
}
开发者ID:GregorioDiStefano,项目名称:core,代码行数:16,代码来源:json_test.c

示例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);
    }
}
开发者ID:ajlill,项目名称:core,代码行数:16,代码来源:json_test.c


注:本文中的JsonParse函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。