Эх сурвалжийг харах

Reduced JSON complexity in ls_std::String class

- reduced complexity of JSON serialization in ls_std::String class by skipping
ls_std::Class serialization part
- adjusted tests
pcmattulat 4 жил өмнө
parent
commit
63f49e5106

+ 0 - 1
source/serialization/boxing/SerializableJSONString.cpp

@@ -33,7 +33,6 @@ void ls_std::SerializableJSONString::unmarshal(const ls_std::byte_field& _data)
 void ls_std::SerializableJSONString::_update()
 {
   this->jsonObject = {
-      {"class", this->value->getClassName()},
       {"value", this->value->toString()}
   };
 }

+ 5 - 5
test/cases/boxing/StringTest.cpp

@@ -3,7 +3,7 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2020-08-14
- * Changed:         2020-08-30
+ * Changed:         2020-09-04
  *
  * */
 
@@ -104,7 +104,7 @@ namespace {
     ls_std::File file {path};
     file.createNewFile();
     ls_std::FileWriter writer {file};
-    writer.write(R"({"class":"String","value":"Hello!"})");
+    writer.write(R"({"value":"Hello!"})");
 
     auto serializable = std::make_shared<ls_std::SerializableJSONString>(x);
     x->setSerializable(std::dynamic_pointer_cast<ls_std::ISerializable>(serializable));
@@ -127,10 +127,10 @@ namespace {
     auto serializable = std::make_shared<ls_std::SerializableJSONString>(x);
     x->setSerializable(std::dynamic_pointer_cast<ls_std::ISerializable>(serializable));
 
-    ASSERT_STREQ(R"({"class":"String","value":"Hello!"})", x->marshal().c_str());
+    ASSERT_STREQ(R"({"value":"Hello!"})", x->marshal().c_str());
 
     *x = "Test!";
-    ASSERT_STREQ(R"({"class":"String","value":"Test!"})", x->marshal().c_str());
+    ASSERT_STREQ(R"({"value":"Test!"})", x->marshal().c_str());
   }
 
   TEST_F(StringTest, parse)
@@ -156,7 +156,7 @@ namespace {
     auto serializable = std::make_shared<ls_std::SerializableJSONString>(x);
     x->setSerializable(std::dynamic_pointer_cast<ls_std::ISerializable>(serializable));
 
-    x->unmarshal(R"({"class":"String","value":"Test!"})");
+    x->unmarshal(R"({"value":"Test!"})");
 
     ASSERT_STREQ("Test!", *x);
   }

+ 3 - 3
test/cases/serialization/boxing/SerializableJSONStringTest.cpp

@@ -3,7 +3,7 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2020-08-30
- * Changed:         2020-08-30
+ * Changed:         2020-09-04
  *
  * */
 
@@ -28,7 +28,7 @@ namespace {
     ls_std::SerializableJSONString serializable {std::make_shared<ls_std::String>(x)};
     ls_std::byte_field content = serializable.marshal();
 
-    ASSERT_STREQ(R"({"class":"String","value":"Testing something!"})", content.c_str());
+    ASSERT_STREQ(R"({"value":"Testing something!"})", content.c_str());
   }
 
   TEST_F(SerializableJSONStringTest, unmarshal)
@@ -37,7 +37,7 @@ namespace {
     ASSERT_STREQ("Hello!", *x);
 
     ls_std::SerializableJSONString serializable {x};
-    serializable.unmarshal(R"({"class":"String","value":"Ups!"})");
+    serializable.unmarshal(R"({"value":"Ups!"})");
 
     ASSERT_STREQ("Ups!", *x);
   }