Add JsonObject::field_count.

This commit is contained in:
levlam 2023-07-31 13:33:35 +03:00
parent 59044294a8
commit 43941c1e69
2 changed files with 6 additions and 2 deletions

View File

@ -226,7 +226,7 @@ static tl_object_ptr<td_api::PaymentProvider> convert_payment_provider(
LOG(ERROR) << "Unsupported JSON data \"" << native_parameters->data_ << '"'; LOG(ERROR) << "Unsupported JSON data \"" << native_parameters->data_ << '"';
return nullptr; return nullptr;
} }
if (value.get_object().field_values_.size() != 1) { if (value.get_object().field_count() != 1) {
LOG(ERROR) << "Unsupported JSON data \"" << native_parameters->data_ << '"'; LOG(ERROR) << "Unsupported JSON data \"" << native_parameters->data_ << '"';
} }
@ -257,7 +257,7 @@ static tl_object_ptr<td_api::PaymentProvider> convert_payment_provider(
LOG(ERROR) << "Unsupported JSON data \"" << native_parameters->data_ << '"'; LOG(ERROR) << "Unsupported JSON data \"" << native_parameters->data_ << '"';
return nullptr; return nullptr;
} }
if (value.get_object().field_values_.size() != 5) { if (value.get_object().field_count() != 5) {
LOG(ERROR) << "Unsupported JSON data \"" << native_parameters->data_ << '"'; LOG(ERROR) << "Unsupported JSON data \"" << native_parameters->data_ << '"';
} }

View File

@ -456,6 +456,10 @@ using JsonArray = vector<JsonValue>;
class JsonObject { class JsonObject {
public: public:
vector<std::pair<MutableSlice, JsonValue>> field_values_; vector<std::pair<MutableSlice, JsonValue>> field_values_;
size_t field_count() const {
return field_values_.size();
}
}; };
class JsonValue final : private Jsonable { class JsonValue final : private Jsonable {