JSON Serializer
Implementing JSONSerializer.
You'll need to include core/
#include <cubos/core/data/ser/serializer.hpp> using cubos::core::data::Serializer; using cubos::core::reflection::Type;
Using the JSON serializer is as simple as calling JSONSerializer::
In this case, we'll be serializing a std::vector<std::vector<std::vector<glm::ivec3>>>
, which is a nested array of objects with three int32_t
fields.
#include <glm/vec3.hpp> #include <cubos/core/reflection/external/glm.hpp> #include <cubos/core/reflection/external/vector.hpp> int main() { std::vector<glm::ivec3> vec{{1, 2, 3}, {4, 5, 6}}; MySerializer ser{}; ser.write(vec); }
This should output:
// [{x: 1, y: 2, z: 3, }, {x: 4, y: 5, z: 6, }, ]