Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix PR#1006 #2158

Merged
merged 4 commits into from
Jun 5, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion include/nlohmann/detail/output/output_adapters.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ class output_string_adapter : public output_adapter_protocol<CharType>
private:
StringType& str;
};

dota17 marked this conversation as resolved.
Show resolved Hide resolved
/// dump to alternative string type, as defined in basic_json template
dota17 marked this conversation as resolved.
Show resolved Hide resolved
/// see https://github.com/nlohmann/json/pull/1006
template<typename CharType, typename StringType = std::basic_string<CharType>>
class output_adapter
{
Expand Down
3 changes: 2 additions & 1 deletion single_include/nlohmann/json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12208,7 +12208,8 @@ class output_string_adapter : public output_adapter_protocol<CharType>
private:
StringType& str;
};

/// dump to alternative string type, as defined in basic_json template
/// see https://github.com/nlohmann/json/pull/1006
template<typename CharType, typename StringType = std::basic_string<CharType>>
class output_adapter
{
Expand Down
4 changes: 2 additions & 2 deletions test/src/unit-alt-string.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,9 @@ TEST_CASE("alternative string type")

{
alt_json doc;
doc["list"] = { 1, 0, 2 };
doc["object"] = { {"currency", "USD"}, {"value", 42.99} };
alt_string dump = doc.dump();
CHECK(dump == R"({"list":[1,0,2]})");
CHECK(dump == R"({"object":{"currency":"USD","value":42.99}})");
}
}

Expand Down