Add get_json_object_field_force.

GitOrigin-RevId: f1e27a7dfb946396917ae347edd68259465f0d87
This commit is contained in:
levlam 2019-10-17 22:22:42 +03:00
parent d919282894
commit 1df4a1c6a4
2 changed files with 11 additions and 0 deletions

View File

@ -593,6 +593,15 @@ bool has_json_object_field(const JsonObject &object, Slice name) {
return false;
}
JsonValue get_json_object_field_force(JsonObject &object, Slice name) {
for (auto &field_value : object) {
if (field_value.first == name) {
return std::move(field_value.second);
}
}
return JsonValue();
}
Result<JsonValue> get_json_object_field(JsonObject &object, Slice name, JsonValue::Type type, bool is_optional) {
for (auto &field_value : object) {
if (field_value.first == name) {

View File

@ -860,6 +860,8 @@ auto json_array(const A &a, F &&f) {
bool has_json_object_field(const JsonObject &object, Slice name);
JsonValue get_json_object_field_force(JsonObject &object, Slice name) TD_WARN_UNUSED_RESULT;
Result<JsonValue> get_json_object_field(JsonObject &object, Slice name, JsonValue::Type type,
bool is_optional = true) TD_WARN_UNUSED_RESULT;