Przeglądaj źródła

dump_json(indent=2)

hewei.it 4 lat temu
rodzic
commit
790ef1a0e8
3 zmienionych plików z 4 dodań i 4 usunięć
  1. 1 1
      http/HttpMessage.cpp
  2. 2 2
      http/http_content.cpp
  3. 1 1
      http/http_content.h

+ 1 - 1
http/HttpMessage.cpp

@@ -331,7 +331,7 @@ void HttpMessage::DumpBody() {
 #ifndef WITHOUT_HTTP_CONTENT
     switch(content_type) {
     case APPLICATION_JSON:
-        body = dump_json(json);
+        body = dump_json(json, 2);
         break;
     case MULTIPART_FORM_DATA:
     {

+ 2 - 2
http/http_content.cpp

@@ -231,8 +231,8 @@ int parse_multipart(std::string& str, MultiPart& mp, const char* boundary) {
     return nparse == str.size() ? 0 : -1;
 }
 
-std::string dump_json(hv::Json& json) {
-    return json.dump();
+std::string dump_json(hv::Json& json, int indent) {
+    return json.dump(indent);
 }
 
 int parse_json(const char* str, hv::Json& json, std::string& errmsg) {

+ 1 - 1
http/http_content.h

@@ -59,7 +59,7 @@ using Json = nlohmann::json;
 // using Json = nlohmann::ordered_json;
 }
 
-HV_EXPORT std::string dump_json(hv::Json& json);
+HV_EXPORT std::string dump_json(hv::Json& json, int indent = -1);
 HV_EXPORT int         parse_json(const char* str, hv::Json& json, std::string& errmsg);
 #endif