// Autogenerated.
// DO NOT EDIT. All changes will be undone.
#pragma once

#include "co/json.h"

namespace xx {

struct XX {
    struct _unamed_s1 {
        int ii;
        fastring ss;

        void from_json(const co::Json& _x_) {
            ii = (int)_x_.get("ii").as_int64();
            ss = _x_.get("ss").as_c_str();
        }

        co::Json as_json() const {
            co::Json _x_;
            _x_.add_member("ii", ii);
            _x_.add_member("ss", ss);
            return _x_;
        }
    };

    struct _unamed_s2 {
        int xx;
        fastring yy;

        void from_json(const co::Json& _x_) {
            xx = (int)_x_.get("xx").as_int64();
            yy = _x_.get("yy").as_c_str();
        }

        co::Json as_json() const {
            co::Json _x_;
            _x_.add_member("xx", xx);
            _x_.add_member("yy", yy);
            return _x_;
        }
    };

    bool b;
    int i;
    fastring s;
    _unamed_s1 data;
    co::vector<int> ai;
    co::vector<_unamed_s2> ao;

    void from_json(const co::Json& _x_) {
        b = _x_.get("b").as_bool();
        i = (int)_x_.get("i").as_int64();
        s = _x_.get("s").as_c_str();
        data.from_json(_x_.get("data"));
        do {
            auto& _unamed_v1 = _x_.get("ai");
            for (uint32 i = 0; i < _unamed_v1.array_size(); ++i) {
                ai.push_back((int)_unamed_v1[i].as_int64());
            }
        } while (0);
        do {
            auto& _unamed_v1 = _x_.get("ao");
            for (uint32 i = 0; i < _unamed_v1.array_size(); ++i) {
                _unamed_s2 _unamed_v2;
                _unamed_v2.from_json(_unamed_v1[i]);
                ao.emplace_back(std::move(_unamed_v2));
            }
        } while (0);
    }

    co::Json as_json() const {
        co::Json _x_;
        _x_.add_member("b", b);
        _x_.add_member("i", i);
        _x_.add_member("s", s);
        _x_.add_member("data", data.as_json());
        do {
            co::Json _unamed_v1;
            for (size_t i = 0; i < ai.size(); ++i) {
                _unamed_v1.push_back(ai[i]);
            }
            _x_.add_member("ai", _unamed_v1);
        } while (0);
        do {
            co::Json _unamed_v1;
            for (size_t i = 0; i < ao.size(); ++i) {
                _unamed_v1.push_back(ao[i].as_json());
            }
            _x_.add_member("ao", _unamed_v1);
        } while (0);
        return _x_;
    }
};

} // xx
