Skip to content

JSON::PrintHandler.value(bool) prints incorrect value #3505

@softhorizons

Description

@softhorizons

This method prints '1' or '0', not 'true' or 'false' on default streams. That is never correct because 0 & 1 are not boolean in JSON.

Example:
std::ostringstream oss;
Poco::JSON::PrintHandler ph(oss);
ph.value(true);
//oss contains "1"

This can be worked around by setting iomanip std::boolalpha in the output stream. Note that boolalpha isn't the default, but that doesn't matter since 1 & 0 are never correct here. Further, JSON specifies that values shall always be 'true' and 'false' whereas c++ streams may localize that.

Probably better to implement as (b ? "true" : "false")

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions