Skip to content

Value(stringValue) stores null pointer, breaks serialisation #517

Closed
@tomalakgeretkal

Description

@tomalakgeretkal
Json::Value v(Json::stringValue);

I would have expected this declaration to store an empty string in v, but instead the internal string pointer is set to 0 and serialisation goes awry:

#include <json/json.h>
#include <iostream>

int main()
{
    Json::Value root;
    root["member"] = Json::stringValue;

    Json::StreamWriterBuilder builder;
    builder["indentation"] = "";
    auto writer = builder.newStreamWriter();
    writer->write(root, &std::cout);
    std::cout << '\n';
}

// Output: {"member":}
// Expected: {"member":""}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions