File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -132,6 +132,20 @@ String icinga::JsonEncode(const Value& value, bool pretty_print)
132
132
return json.dump (pretty_print ? l_JsonIndentSize : -1 , ' ' , true );
133
133
}
134
134
135
+ /* *
136
+ * Serializes an Icinga Value into a JSON object and writes it to the given output stream.
137
+ *
138
+ * @param value The value to be JSON serialized.
139
+ * @param os The output stream to write the JSON data to.
140
+ * @param pretty_print Whether to pretty print the JSON data.
141
+ */
142
+ void icinga::JsonEncode (const Value& value, std::ostream& os, bool pretty_print)
143
+ {
144
+ using namespace nlohmann ;
145
+ detail::serializer<json> s (nlohmann::detail::output_adapter (os), ' ' , json::error_handler_t ::strict);
146
+ s.dump (json (value), pretty_print, true , pretty_print ? l_JsonIndentSize : 0 );
147
+ }
148
+
135
149
Value icinga::JsonDecode (const String& data)
136
150
{
137
151
String sanitized (Utility::ValidateUTF8 (data));
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ class String;
12
12
class Value ;
13
13
14
14
String JsonEncode (const Value& value, bool pretty_print = false );
15
+ void JsonEncode (const Value& value, std::ostream& os, bool pretty_print = false );
15
16
Value JsonDecode (const String& data);
16
17
17
18
}
You can’t perform that action at this time.
0 commit comments