#define UNIT r5_json #include "test_main.cpp" #include std::string escape( const std::string &in ) { std::ostringstream ostr; for ( char c : in ) { if ( c == '\\' || c == '"' ) ostr << "\\"; ostr << c; } return ostr.str(); } std::string to_json( const str_dict &dict ) { std::ostringstream ostr; ostr << "{"; bool comma = false; for ( auto [ k, v ] : dict ) { ostr << ( comma ? ", " : " " ); comma = true; ostr << "\"" << escape( k ) << "\": \"" << escape( v ) << "\""; } ostr << ( comma ? " }" : "}" ); return ostr.str(); }