MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / forEachChild

Function forEachChild

source/json_tool/json_tool.cpp:132–145  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

130}
131
132void forEachChild(FormattedJson const& parent, function<void(FormattedJson const&)> func) {
133 if (parent.isType(Json::Type::Object)) {
134 for (String const& key : parent.toJson().toObject().keys()) {
135 func(parent.get(key));
136 }
137 } else if (parent.isType(Json::Type::Array)) {
138 for (size_t i = 0; i < parent.size(); ++i) {
139 func(parent.get(i));
140 }
141 } else {
142 throw JsonPath::TraversalException::format(
143 "Cannot get the children of Json type {}, must be either Array or Object", parent.typeName());
144 }
145}
146
147bool process(function<void(FormattedJson const&)> output,
148 Command const& command,

Callers 1

processFunction · 0.85

Calls 9

funcFunction · 0.85
toObjectMethod · 0.80
formatFunction · 0.50
isTypeMethod · 0.45
keysMethod · 0.45
toJsonMethod · 0.45
getMethod · 0.45
sizeMethod · 0.45
typeNameMethod · 0.45

Tested by

no test coverage detected