小编ste*_*ebl的帖子

Poco C++构建嵌套的JSON对象

我有一个嵌套的JSON对象.我正在尝试在函数中构建它并将内部对象添加到原始对象中,但我无法提取结果.

void build_object (Poco::JSON::Object * const result)
{

    /* Construct some int/bool/string fields here */

    Poco::JSON::Object inner;
    inner.set("some_number", 5);
    inner.set("some_string", "xyz");

    /* This is where it breaks down */ 
    std::string key = "new_object";
    result->set("new_object", inner);

    /* Then some debugging and testing */
    // The new object is printed inside the first -> seems like it's working
    result->stringify(std::cout); 

    printf("result has(key): %i\n", result->has(key)); // true
    printf("isObject: %i\n", result->isObject(key));   // false - huh?
    printf("isNull: %i\n", result->isNull(key));       // false
    printf("isArray: %i\n", result->isArray(key));     // false …
Run Code Online (Sandbox Code Playgroud)

c++ json poco-libraries

6
推荐指数
1
解决办法
7707
查看次数

标签 统计

c++ ×1

json ×1

poco-libraries ×1