12345678910111213141516171819202122232425262728293031323334353637 |
- /*
- * Author: Patrick-Christopher Mattulat
- * Company: Lynar Studios
- * E-Mail: webmaster@lynarstudios.com
- * Created: 2020-09-04
- * Changed: 2020-11-06
- *
- * */
- #include "../../../../../include/ls_std/serialization/boxing/SerializableJSONBoolean.hpp"
- ls_std::SerializableJSONBoolean::SerializableJSONBoolean(std::shared_ptr<ls_std::Boolean> _value) :
- Class("SerializableJSONBoolean"),
- value(std::move(_value))
- {}
- ls_std::byte_field ls_std::SerializableJSONBoolean::marshal()
- {
- this->_update();
- return this->jsonObject.dump();
- }
- void ls_std::SerializableJSONBoolean::unmarshal(const ls_std::byte_field& _data)
- {
- this->jsonObject = nlohmann::json::parse(_data);
- if(this->jsonObject.contains("value")) {
- *this->value = (bool) this->jsonObject["value"];
- }
- }
- void ls_std::SerializableJSONBoolean::_update()
- {
- this->jsonObject = {
- {"value", this->value->getValue()}
- };
- }
|