Skip to content

Commit 4bc910b

Browse files
fix: leave arrays in json (googleapis#13052)
This functionality replaces all arrays with `<discarded>` value, making the json invalid. It happens even if the array is not empty.
1 parent 09cfff7 commit 4bc910b

2 files changed

Lines changed: 0 additions & 14 deletions

File tree

google/cloud/bigquery/v2/minimal/internal/json_utils.cc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,6 @@ nlohmann::json RemoveJsonKeysAndEmptyFields(
109109
if (event == nlohmann::json::parse_event_t::object_end) {
110110
return parsed != nullptr && !parsed.empty();
111111
}
112-
if (event == nlohmann::json::parse_event_t::array_end) {
113-
return !parsed.empty();
114-
}
115112
return true;
116113
};
117114
return nlohmann::json::parse(json_payload, remove_empty_call_back, false);

google/cloud/bigquery/v2/minimal/internal/json_utils_test.cc

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -229,17 +229,6 @@ TEST(JsonUtilsTest, RemoveKeys) {
229229
EXPECT_EQ(expected, json.dump());
230230
}
231231

232-
TEST(JsonUtilsTest, RemoveEmptyArrays) {
233-
std::vector<std::string> keys = {"start_time", "query_parameters"};
234-
auto constexpr kJsonText =
235-
R"({"start_time":"10", "project_id": "1", "query_parameters":[]})";
236-
237-
auto json = RemoveJsonKeysAndEmptyFields(kJsonText, keys);
238-
auto const* expected = R"({"project_id":"1"})";
239-
240-
EXPECT_EQ(expected, json.dump());
241-
}
242-
243232
TEST(JsonUtilsTest, RemoveEmptyObjects) {
244233
std::vector<std::string> keys = {"start_time", "query"};
245234
auto constexpr kJsonText =

0 commit comments

Comments
 (0)