# struct utils::SerializableJson

## Overview

Abstration of a class that supports serialization to json strings. More…

    #include <SerializableJson.h>

    struct SerializableJson {
        // methods

        std::string Serialize() const;
        bool Deserialize(const std::string& json_string);
        virtual void AddToJsonNode(nlohmann::json& parent_node) const = 0;
        virtual bool ReadFromJsonNode(const nlohmann::json& parent_node) = 0;
    };

## Detailed Documentation

Abstration of a class that supports serialization to json strings.

When inheriting this class, be sure to overload methods AddToJsonNode and ReadFromJsonNode, that should contain implementation of your json serialization.

### Methods

    std::string Serialize() const

Stores object to json string.

    bool Deserialize(const std::string& json_string)

Loads object from json string.

    virtual void AddToJsonNode(nlohmann::json& parent_node) const = 0

Fill data of this to json node.

    virtual bool ReadFromJsonNode(const nlohmann::json& parent_node) = 0

Read json node and initialize this.

Parameters:

nlohmann::json::exception | when required keys are missing.