Add PrintTo for dynamic
[folly.git] / folly / json.cpp
index 63fa2ba08dc7236577d73de4e781f04be132ce3c..438cdf2ed7a4bc833c059a7b6c05e0d569c033ee 100644 (file)
@@ -833,6 +833,15 @@ void dynamic::print_as_pseudo_json(std::ostream& out) const {
   out << json::serialize(*this, opts);
 }
 
+void PrintTo(const dynamic& dyn, std::ostream* os) {
+  json::serialization_opts opts;
+  opts.allow_nan_inf = true;
+  opts.allow_non_string_keys = true;
+  opts.pretty_formatting = true;
+  opts.sort_keys = true;
+  *os << json::serialize(dyn, opts);
+}
+
 //////////////////////////////////////////////////////////////////////
 
 }