| 168 | } |
| 169 | |
| 170 | std::optional<Json> jsonValueByPath(Json const& _node, std::string_view _jsonPath) |
| 171 | { |
| 172 | if (!_node.is_object() || _jsonPath.empty()) |
| 173 | return {}; |
| 174 | |
| 175 | std::string memberName = std::string(_jsonPath.substr(0, _jsonPath.find_first_of('.'))); |
| 176 | if (!_node.contains(memberName)) |
| 177 | return {}; |
| 178 | |
| 179 | if (memberName == _jsonPath) |
| 180 | return _node[memberName]; |
| 181 | |
| 182 | return jsonValueByPath(_node[memberName], _jsonPath.substr(memberName.size() + 1)); |
| 183 | } |
| 184 | |
| 185 | } // namespace solidity::util |