SAX like builder of JSON string. Use with extreme caution and only in performance critical part of your code.
More...
#include <userver/formats/json/string_builder.hpp>
SAX like builder of JSON string. Use with extreme caution and only in performance critical part of your code.
Prefer using WriteToStream function to add data to the StringBuilder.
Example usage:
struct MyKeyValue {
std::string field1;
int field2;
};
inline void WriteToStream(const MyKeyValue& data,
WriteToStream(data.field1, sw);
WriteToStream(data.field2, sw);
}
TEST(JsonStringBuilder, ExampleUsage) {
StringBuilder sb;
MyKeyValue data = {"one", 1};
ASSERT_EQ(sb.GetString(), "{\"field1\":\"one\",\"field2\":1}");
}
}
- See also
- Formats (JSON, YAML, BSON, ...)
Definition at line 36 of file string_builder.hpp.
◆ Value
◆ GetString()
std::string formats::json::StringBuilder::GetString |
( |
| ) |
const |
The documentation for this class was generated from the following file: