From 407a8442f85325f6b827211917d1a1e6c5070fbb Mon Sep 17 00:00:00 2001 From: levlam Date: Sun, 20 May 2018 16:16:16 +0300 Subject: [PATCH] Fix null @extra in JSON interface. GitOrigin-RevId: 1a470608d7cfbf58b55952eb3162e54d7ec245b7 --- td/telegram/ClientJson.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/td/telegram/ClientJson.cpp b/td/telegram/ClientJson.cpp index 9e3cbc226..e5fd44329 100644 --- a/td/telegram/ClientJson.cpp +++ b/td/telegram/ClientJson.cpp @@ -24,12 +24,11 @@ Result ClientJson::to_request(Slice request) { if (json_value.type() != JsonValue::Type::Object) { return Status::Error("Expected an Object"); } - TRY_RESULT(extra_field, get_json_object_field(json_value.get_object(), "@extra", JsonValue::Type::Null, true)); std::uint64_t extra_id = extra_id_.fetch_add(1, std::memory_order_relaxed); - auto extra_str = json_encode(extra_field); - if (!extra_str.empty()) { + if (has_json_object_field(json_value.get_object(), "@extra")) { std::lock_guard guard(mutex_); - extra_[extra_id] = std::move(extra_str); + extra_[extra_id] = json_encode( + get_json_object_field(json_value.get_object(), "@extra", JsonValue::Type::Null).move_as_ok()); } td_api::object_ptr func;