MCPcopy Create free account
hub / github.com/Open-GD/OpenGD / to_json

Method to_json

Source/NodeSerializer.cpp:40–83  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

38constexpr int indentation = 2;
39
40void NodeSerializer::to_json(ordered_json& j, const ax::Node* p)
41{
42 j = ordered_json{
43 {"type", getNodeName(p)},
44 {"pos", {
45 {"x", p->getPositionX()},
46 {"y", p->getPositionY()}
47 }},
48 {"scale", {
49 {"x", p->getScaleX()},
50 {"y", p->getScaleY()}
51 }},
52 {"rot", {
53 {"x", p->getRotationSkewX()},
54 {"y", p->getRotationSkewY()}
55 }},
56 {"anchor", {
57 {"x", p->getAnchorPoint().x},
58 {"y", p->getAnchorPoint().y}
59 }},
60 {"contentSize", {
61 {"width", p->getContentSize().width},
62 {"height", p->getContentSize().height}
63 }},
64 {"color", {
65 {"r", p->getColor().r},
66 {"g", p->getColor().g},
67 {"b", p->getColor().b}
68 }},
69 {"zOrder", p->getGlobalZOrder()},
70 {"visible", p->isVisible()}
71 };
72
73 const auto& children = p->getChildren();
74 if (!children.empty()) {
75 ordered_json childrenJson;
76 for (const auto& child : children) {
77 ordered_json childJson;
78 to_json(childJson, child);
79 childrenJson.push_back(childJson);
80 }
81 j["children"] = childrenJson;
82 }
83}
84
85//untested
86void NodeSerializer::from_json(const ordered_json& j, ax::Node* p)

Callers

nothing calls this directly

Calls 4

to_jsonFunction · 0.85
getColorMethod · 0.80
emptyMethod · 0.80
getNodeNameFunction · 0.70

Tested by

no test coverage detected