|
@@ -66,7 +66,7 @@ public:
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
|
|
-void GenerateDeepJson(TStringStream& stream, ui64 depth) {
|
|
|
|
|
|
+void GenerateDeepJsonArray(TStringStream& stream, ui64 depth) {
|
|
stream << "{\"key\":";
|
|
stream << "{\"key\":";
|
|
for (ui32 i = 0; i < depth - 1; ++i) {
|
|
for (ui32 i = 0; i < depth - 1; ++i) {
|
|
stream << "[";
|
|
stream << "[";
|
|
@@ -77,6 +77,16 @@ void GenerateDeepJson(TStringStream& stream, ui64 depth) {
|
|
stream << "}";
|
|
stream << "}";
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+void GenerateDeepJsonDict(TStringStream& stream, ui64 depth) {
|
|
|
|
+ for (ui64 i = 0; i < depth - 1; ++i) {
|
|
|
|
+ stream << "{\"key\":";
|
|
|
|
+ }
|
|
|
|
+ stream << "{}";
|
|
|
|
+ for (ui64 i = 0; i < depth - 1; ++i) {
|
|
|
|
+ stream << "}";
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
Y_UNIT_TEST_SUITE(TJsonReaderTest) {
|
|
Y_UNIT_TEST_SUITE(TJsonReaderTest) {
|
|
Y_UNIT_TEST(JsonReformatTest) {
|
|
Y_UNIT_TEST(JsonReformatTest) {
|
|
TString data = "{\"null value\": null, \"intkey\": 10, \"double key\": 11.11, \"string key\": \"string\", \"array\": [1,2,3,\"TString\"], \"bool key\": true}";
|
|
TString data = "{\"null value\": null, \"intkey\": 10, \"double key\": 11.11, \"string key\": \"string\", \"array\": [1,2,3,\"TString\"], \"bool key\": true}";
|
|
@@ -414,7 +424,7 @@ Y_UNIT_TEST_SUITE(TJsonReaderTest) {
|
|
constexpr ui32 brackets = static_cast<ui32>(1e5);
|
|
constexpr ui32 brackets = static_cast<ui32>(1e5);
|
|
|
|
|
|
TStringStream jsonStream;
|
|
TStringStream jsonStream;
|
|
- GenerateDeepJson(jsonStream, brackets);
|
|
|
|
|
|
+ GenerateDeepJsonArray(jsonStream, brackets);
|
|
|
|
|
|
TJsonReaderConfig config;
|
|
TJsonReaderConfig config;
|
|
config.UseIterativeParser = true;
|
|
config.UseIterativeParser = true;
|
|
@@ -429,7 +439,25 @@ Y_UNIT_TEST_SUITE(TJsonReaderTest) {
|
|
|
|
|
|
{
|
|
{
|
|
TStringStream jsonStream;
|
|
TStringStream jsonStream;
|
|
- GenerateDeepJson(jsonStream, depth);
|
|
|
|
|
|
+ GenerateDeepJsonArray(jsonStream, depth);
|
|
|
|
+ TJsonReaderConfig config;
|
|
|
|
+ config.MaxDepth = depth;
|
|
|
|
+ TJsonValue v;
|
|
|
|
+ UNIT_ASSERT(ReadJsonTree(&jsonStream, &config, &v));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ {
|
|
|
|
+ TStringStream jsonStream;
|
|
|
|
+ GenerateDeepJsonArray(jsonStream, depth);
|
|
|
|
+ TJsonReaderConfig config;
|
|
|
|
+ config.MaxDepth = depth - 1;
|
|
|
|
+ TJsonValue v;
|
|
|
|
+ UNIT_ASSERT(!ReadJsonTree(&jsonStream, &config, &v));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ {
|
|
|
|
+ TStringStream jsonStream;
|
|
|
|
+ GenerateDeepJsonDict(jsonStream, depth);
|
|
TJsonReaderConfig config;
|
|
TJsonReaderConfig config;
|
|
config.MaxDepth = depth;
|
|
config.MaxDepth = depth;
|
|
TJsonValue v;
|
|
TJsonValue v;
|
|
@@ -438,7 +466,7 @@ Y_UNIT_TEST_SUITE(TJsonReaderTest) {
|
|
|
|
|
|
{
|
|
{
|
|
TStringStream jsonStream;
|
|
TStringStream jsonStream;
|
|
- GenerateDeepJson(jsonStream, depth);
|
|
|
|
|
|
+ GenerateDeepJsonDict(jsonStream, depth);
|
|
TJsonReaderConfig config;
|
|
TJsonReaderConfig config;
|
|
config.MaxDepth = depth - 1;
|
|
config.MaxDepth = depth - 1;
|
|
TJsonValue v;
|
|
TJsonValue v;
|