| 130 | } |
| 131 | |
| 132 | void 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 | |
| 147 | bool process(function<void(FormattedJson const&)> output, |
| 148 | Command const& command, |