diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ef6fe9..ddb2fdd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -59,8 +59,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Fixed -1. Fix issue where [random string from regex](/docs/README.md#random-strings-from-regex-added-in-v81) would incorrectly flag some valid regular expressions (e.g. `(?-i)(?:xy{1,2}){,2}`) as having two consecutive quantifiers. +1. Fix the following issues with [random string from regex](/docs/README.md#random-strings-from-regex-added-in-v81): + - It previously incorrectly flagged some valid regular expressions (e.g. `(?-i)(?:xy{1,2}){,2}`) as having two consecutive quantifiers. + - It previously did not correctly handle some character sets where the final character was `-` (for example, `[+-]` previously would only generate `+`, and now it correctly has a 50% chance of generating `-` or `+`) 2. Fix issue where RemesPath incorrectly inferred the type of (a [function](/docs/RemesPath.md#functions) `fun` followed by [indexers](/docs/RemesPath.md#indexing-and-selecting-keys)) to be the return type of `fun`. For example, running the query `sum(dict(items(@)).a)` on the JSON `{"a": [1]}` now correctly returns `1.0`, but RemesPath *used to raise an error because it assumed that `dict(items(@)).a` had the same type as `dict(items(@))`* +3. Fix very rare crash bug when using the `Value to clipboard` option of the [tree node right-click context menu](/docs/README.md#get-info-about-tree-nodes). +4. Fix bug where some invalid JSON Lines documents (for example, `[1, \n2][3]`) would be accepted by the [JSON Lines parser](/docs/README.md#json-lines-documents) despite having elements that span multiple lines. ## [8.1.0] - 2024-08-23 diff --git a/JsonToolsNppPlugin/Forms/TreeViewer.cs b/JsonToolsNppPlugin/Forms/TreeViewer.cs index 77e5a48..239f8bf 100644 --- a/JsonToolsNppPlugin/Forms/TreeViewer.cs +++ b/JsonToolsNppPlugin/Forms/TreeViewer.cs @@ -858,7 +858,7 @@ private static void JsonTreePopulate_FullRecursive(TreeView tree, /// /// On right click, throw up a context menu that lets you do the following:

- /// - Copy the current node's value to the clipboard

+ /// - Copy the current node's value to the clipboard (unless it's an array or object, in which case do nothing)

/// - Copy the node's path (Python style) to the clipboard

/// - Copy the node's key/index (Python style) to the clipboard

/// - Copy the node's path (JavaScript style) to the clipboard

@@ -885,8 +885,8 @@ private void Tree_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e) valToClipboardHandler = new MouseEventHandler( (object sender2, MouseEventArgs e2) => { - JNode jnode = pathsToJNodes[node.FullPath]; - if (jnode is JObject || jnode is JArray) + if (!pathsToJNodes.TryGetValue(node.FullPath, out JNode jnode) + || jnode is JObject || jnode is JArray) return; Npp.TryCopyToClipboard(jnode.ToString()); } diff --git a/JsonToolsNppPlugin/JSONTools/JsonParser.cs b/JsonToolsNppPlugin/JSONTools/JsonParser.cs index 72c88f2..acfb48b 100644 --- a/JsonToolsNppPlugin/JSONTools/JsonParser.cs +++ b/JsonToolsNppPlugin/JSONTools/JsonParser.cs @@ -1799,17 +1799,25 @@ public JNode ParseJsonLines(string inp) while (ii < inp.Length) { json = ParseSomething(inp, 0); + int endOfLastJson = ii; ConsumeInsignificantChars(inp); children.Add(json); if (fatal) { return arr; } - int maxLastII = ii > inp.Length ? inp.Length : ii; + int maxLastII = ii > inp.Length ? inp.Length : ii; for (; lastII < maxLastII; lastII++) { if (inp[lastII] == '\n') + { + if (lastII < endOfLastJson) // for example, "[1,\n2]" is invalid JSON Lines, but "[1,2]\n" is OK because the newline is trailing + { + HandleError(JsonLintType.FATAL_JSONL_NOT_ONE_DOC_PER_LINE, inp, lastII); + return arr; + } lineNum++; + } } // make sure this document was all in one line if (!(lineNum == arr.Length diff --git a/JsonToolsNppPlugin/Properties/AssemblyInfo.cs b/JsonToolsNppPlugin/Properties/AssemblyInfo.cs index f9d6ae0..4f42941 100644 --- a/JsonToolsNppPlugin/Properties/AssemblyInfo.cs +++ b/JsonToolsNppPlugin/Properties/AssemblyInfo.cs @@ -28,5 +28,5 @@ // Build Number // Revision // -[assembly: AssemblyVersion("8.1.0.2")] -[assembly: AssemblyFileVersion("8.1.0.2")] +[assembly: AssemblyVersion("8.1.0.3")] +[assembly: AssemblyFileVersion("8.1.0.3")] diff --git a/JsonToolsNppPlugin/Tests/JsonParserTests.cs b/JsonToolsNppPlugin/Tests/JsonParserTests.cs index b3e2418..ccefcbb 100644 --- a/JsonToolsNppPlugin/Tests/JsonParserTests.cs +++ b/JsonToolsNppPlugin/Tests/JsonParserTests.cs @@ -1138,34 +1138,43 @@ public static bool TestLinter() public static bool TestJsonLines() { - JsonParser parser = new JsonParser(); - var testcases = new string[][] + JsonParser parser = new JsonParser(LoggerLevel.JSON5, false, false); + var testcases = new (string input, string desiredOutStr)[] { - new string[] - { + ( "[\"a\", \"b\"]\r\n" + "{\"a\": false, \"b\": 2}\r\n" + "null\r\n" + "1.5", // normal style "[[\"a\", \"b\"], {\"a\": false, \"b\": 2}, null, 1.5]" - }, - new string[] - { + ), + ( "[1, 2]\n[3, 4]\n", // newline at end "[[1, 2], [3, 4]]" - }, - new string[] - { + ), + ( "{\"a\": [1, 2], \"b\": -7.8}", // single document "[{\"a\": [1, 2], \"b\": -7.8}]" - }, + ), + ( + "[1, 2] // foo\r\n", // single doc with comment at end + "[[1, 2]]" + ), + ( + "{foo: {bar: 1., baz: [null, /* bunrmeme */ False]}}", + "[{\"foo\": {\"bar\": 1.0, \"baz\": [null, false]}}]" + ), + ( + // honestly this should probably be invalid b/c one of the line breaks is inside a comment, but JsonTools should accept it anyway + "\"nbn\" # py\r\n -.75 /* mul \n */undefined\n", + "[\"nbn\", -0.75, null]" + ) }; int testsFailed = 0; int ii = 0; - foreach (string[] test in testcases) + foreach ((string input, string desiredOutStr) in testcases) { - string input = test[0]; - JNode desiredOutput = TryParse(test[1], parser); + JNode desiredOutput = TryParse(desiredOutStr, parser); JNode json = TryParse(input, parser, true); if (json == null) { @@ -1181,20 +1190,22 @@ public static bool TestJsonLines() {1} Got {2} ", - ii + 1, test[1], json.ToString())); + ii + 1, desiredOutStr, json.ToString())); } } string[] shouldThrowTestcases = new string[] { "[1,\n2]\n[3, 4]", // one doc covers multiple lines - "[1, 2]\n\n3", // two lines between docs + "[1, 2]\n // fjfjfj\n3", // two lines between docs "[1, 2] [3, 4]", // two docs on same line "", // empty input - "[1, 2]\n[3, 4", // final doc is invalid - "[1, 2\n[3, 4]", // first doc is invalid - "[1, 2]\nd", // bad char at EOF - "[1, 2]\n\n", // multiple newlines after last doc + "[1, 2]\n[3, 0xH", // final doc is invalid (0xH is not valid hex number) + "[1, fals\n[3, 4]", // first doc is invalid (invalid literal starting with 'f') + "[1, 2]\nd", // bad char 'd' where a new JSON line or EOF expected + "[1, 2]\n # foo\n", // multiple newlines after last doc + "[1,\n2][3, 4]", // doc covering multiple lines with no newline before next doc + "{\"a\": 1}/* bnkk\n */{\"b\": 2}\r\n[1.5,\n3]", // doc covering multiple lines with no newline before EOF }; foreach (string test in shouldThrowTestcases) @@ -1203,8 +1214,11 @@ public static bool TestJsonLines() try { JNode json = parser.ParseJsonLines(test); - testsFailed++; - Npp.AddLine($"Expected JSON Lines parser to throw an error on input\n{test}\nbut instead returned {json.ToString()}"); + if (!parser.fatal) + { + testsFailed++; + Npp.AddLine($"Expected JSON Lines parser to throw an error on input\n{test}\nbut instead returned {json.ToString()}"); + } } catch { } } diff --git a/JsonToolsNppPlugin/Tests/RandomStringFromRegexTests.cs b/JsonToolsNppPlugin/Tests/RandomStringFromRegexTests.cs index f133b8c..d0c835d 100644 --- a/JsonToolsNppPlugin/Tests/RandomStringFromRegexTests.cs +++ b/JsonToolsNppPlugin/Tests/RandomStringFromRegexTests.cs @@ -47,6 +47,7 @@ public static bool Test() "ba ba \tba", "ba ba \tbaba", "ba ba \tbababa" }), (@"(?-i)(?:xy{1,2}){,2}", new HashSet{"", "xy", "xyy", "xyxy", "xyxyy", "xyyxy", "xyyxyy"}), (@"(b|g{3})?", new HashSet{"", "b", "ggg"}), + ("[a-][b-c-]|[hij-][-][+]", new HashSet{"ab", "ac", "a-", "-b", "-c", "--", "h-+", "i-+", "j-+", "--+"}), }; ii += simpleTestcases.Length * 2; diff --git a/JsonToolsNppPlugin/Utils/RandomStringFromRegex.cs b/JsonToolsNppPlugin/Utils/RandomStringFromRegex.cs index 2d75ba3..85cf486 100644 --- a/JsonToolsNppPlugin/Utils/RandomStringFromRegex.cs +++ b/JsonToolsNppPlugin/Utils/RandomStringFromRegex.cs @@ -717,7 +717,7 @@ private RandomStringFromRegex(string regex) tryCharRange = false; precededByCharRange = true; } - else if (d == '-' && jj > firstTokenInCurrentState && !precededByCharRange) + else if (d == '-' && jj > firstTokenInCurrentState && jj < tokens.Count - 1 && !precededByCharRange) tryCharRange = true; else { diff --git a/most recent errors.txt b/most recent errors.txt index f4ac474..eac6f8b 100644 --- a/most recent errors.txt +++ b/most recent errors.txt @@ -1,4 +1,4 @@ -Test results for JsonTools v8.1.0.2 on Notepad++ 8.6.9 64bit +Test results for JsonTools v8.1.0.3 on Notepad++ 8.6.9 64bit NOTE: Ctrl-F (regular expressions *on*) for "Failed [1-9]\d*" to find all failed tests Tests failed: YAML dumper ========================= @@ -46,7 +46,7 @@ Testing JSON Lines parser ========================= Failed 0 tests. -Passed 8 tests. +Passed 10 tests. ========================= Testing parsing of numbers does not depend on current culture ========================= @@ -169,7 +169,7 @@ Testing Random string from regex ========================= Failed 0 tests. -Passed 59 tests. +Passed 61 tests. ========================= Testing generation of random JSON from schema ========================= @@ -206,33 +206,33 @@ Testing JsonParser performance Preview of json: [{"A": "Ky'c^g#~)0", "a": 1850111954, "b": 9318359041, "B": "Oyi:/ xxe2", "C": "sKCSa_^7Gg", "c": 7974777124, "d": 2670309238, "D": "0d_K)HmX!.", "E": ".uM*Z{0EJ_", "e": 6958410336, "f": 8050244728, "F": "1%SG_A!xB\t", "g": 3799657125, "G": "il1^k\\\nat*", "H": {"a": 6079042826, "b": 7292804611, "c" ... -To convert JSON string of size 89556 into JNode took 3.749 +/- 2.351 ms over 32 trials -Load times (ms): 3, 2, 2, 8, 1, 6, 3, 6, 2, 2, 8, 1, 1, 2, 5, 1, 1, 7, 2, 1, 2, 6, 2, 2, 8, 1, 2, 2, 6, 2, 2, 7 +To convert JSON string of size 89556 into JNode took 2.928 +/- 2.167 ms over 32 trials +Load times (ms): 2, 1, 1, 5, 1, 2, 7, 9, 1, 1, 3, 1, 1, 6, 1, 1, 1, 3, 1, 1, 6, 1, 1, 1, 4, 1, 1, 6, 1, 1, 1, 4 ========================= Performance tests for RemesPath (float arithmetic) ========================= -Compiling query "@[@[:].a * @[:].t < @[:].e]" took 0.106 ms the first time, including approximately 0.106 ms to tokenize the query. Subsequent executions are effectively free due to caching. -To run pre-compiled query "@[@[:].a * @[:].t < @[:].e]" on JNode from JSON of size 89556 into took 0.032 +/- 0.011 ms over 40 trials -Query times (ms): 0.073, 0.032, 0.038, 0.037, 0.036, 0.037, 0.037, 0.029, 0.022, 0.023, 0.023, 0.022, 0.023, 0.026, 0.024, 0.023, 0.023, 0.024, 0.024, 0.028, 0.023, 0.024, 0.023, 0.023, 0.023, 0.026, 0.023, 0.022, 0.036, 0.024, 0.031, 0.06, 0.043, 0.041, 0.04, 0.042, 0.041, 0.041, 0.042, 0.04 +Compiling query "@[@[:].a * @[:].t < @[:].e]" took 0.064 ms the first time, including approximately 0.124 ms to tokenize the query. Subsequent executions are effectively free due to caching. +To run pre-compiled query "@[@[:].a * @[:].t < @[:].e]" on JNode from JSON of size 89556 into took 0.024 +/- 0.007 ms over 40 trials +Query times (ms): 0.063, 0.033, 0.022, 0.023, 0.022, 0.022, 0.022, 0.028, 0.023, 0.022, 0.022, 0.022, 0.022, 0.025, 0.022, 0.022, 0.023, 0.022, 0.022, 0.024, 0.023, 0.022, 0.022, 0.023, 0.022, 0.024, 0.022, 0.023, 0.022, 0.022, 0.022, 0.025, 0.022, 0.022, 0.022, 0.023, 0.022, 0.026, 0.022, 0.022 Preview of result: [{"A": "Ky'c^g#~)0", "a": 1850111954, "b": 9318359041, "B": "Oyi:/ xxe2", "C": "sKCSa_^7Gg", "c": 7974777124, "d": 2670309238, "D": "0d_K)HmX!.", "E": ".uM*Z{0EJ_", "e": 6958410336, "f": 8050244728, "F": "1%SG_A!xB\t", "g": 3799657125, "G": "il1^k\\\nat*", "H": {"a": 6079042826, "b": 7292804611, "c" ... ========================= Performance tests for RemesPath (string operations) ========================= -Compiling query "@[@[:].z =~ `(?i)[a-z]{5}`]" took 0.066 ms the first time, including approximately 0.072 ms to tokenize the query. Subsequent executions are effectively free due to caching. -To run pre-compiled query "@[@[:].z =~ `(?i)[a-z]{5}`]" on JNode from JSON of size 89556 into took 0.072 +/- 0.022 ms over 40 trials -Query times (ms): 0.166, 0.106, 0.069, 0.087, 0.071, 0.089, 0.089, 0.055, 0.075, 0.085, 0.055, 0.053, 0.053, 0.052, 0.081, 0.078, 0.054, 0.052, 0.053, 0.087, 0.072, 0.059, 0.084, 0.072, 0.053, 0.054, 0.053, 0.084, 0.072, 0.053, 0.054, 0.062, 0.108, 0.089, 0.085, 0.054, 0.069, 0.074, 0.064, 0.055 +Compiling query "@[@[:].z =~ `(?i)[a-z]{5}`]" took 0.072 ms the first time, including approximately 0.155 ms to tokenize the query. Subsequent executions are effectively free due to caching. +To run pre-compiled query "@[@[:].z =~ `(?i)[a-z]{5}`]" on JNode from JSON of size 89556 into took 0.055 +/- 0.008 ms over 40 trials +Query times (ms): 0.098, 0.057, 0.054, 0.053, 0.055, 0.052, 0.053, 0.053, 0.052, 0.052, 0.054, 0.053, 0.053, 0.054, 0.053, 0.053, 0.053, 0.053, 0.053, 0.053, 0.053, 0.054, 0.053, 0.053, 0.078, 0.056, 0.053, 0.053, 0.052, 0.052, 0.053, 0.052, 0.053, 0.053, 0.052, 0.053, 0.052, 0.052, 0.052, 0.053 Preview of result: [{"A": "\n]o1VQ5t6g", "a": 4710024278, "b": 3268860721, "B": "g4Y7+ew^.v", "C": "NK nmax_notq, `when q=true, nmax = ` + str(nmax_q), `when q=false, nmax= ` + str(nmax_notq))" took 0.252 ms the first time, including approximately 0.2 ms to tokenize the query. Subsequent executions are effectively free due to caching. +ifelse(nmax_q > nmax_notq, `when q=true, nmax = ` + str(nmax_q), `when q=false, nmax= ` + str(nmax_notq))" took 0.139 ms the first time, including approximately 0.177 ms to tokenize the query. Subsequent executions are effectively free due to caching. To run pre-compiled query "var qmask = @[:].q; var nmax_q = max(@[qmask].n); var nmax_notq = max(@[not qmask].n); -ifelse(nmax_q > nmax_notq, `when q=true, nmax = ` + str(nmax_q), `when q=false, nmax= ` + str(nmax_notq))" on JNode from JSON of size 89556 into took 0.029 +/- 0.017 ms over 40 trials -Query times (ms): 0.131, 0.03, 0.026, 0.026, 0.037, 0.025, 0.054, 0.026, 0.024, 0.025, 0.024, 0.024, 0.03, 0.024, 0.026, 0.024, 0.023, 0.022, 0.025, 0.023, 0.024, 0.024, 0.025, 0.025, 0.024, 0.024, 0.024, 0.023, 0.025, 0.024, 0.024, 0.023, 0.024, 0.025, 0.024, 0.024, 0.024, 0.035, 0.025, 0.024 +ifelse(nmax_q > nmax_notq, `when q=true, nmax = ` + str(nmax_q), `when q=false, nmax= ` + str(nmax_notq))" on JNode from JSON of size 89556 into took 0.036 +/- 0.057 ms over 40 trials +Query times (ms): 0.101, 0.031, 0.017, 0.016, 0.028, 0.015, 0.016, 0.019, 0.233, 0.016, 0.023, 0.015, 0.082, 0.015, 0.017, 0.016, 0.015, 0.015, 0.015, 0.024, 0.014, 0.027, 0.015, 0.015, 0.015, 0.015, 0.015, 0.016, 0.016, 0.119, 0.048, 0.016, 0.015, 0.015, 0.015, 0.015, 0.015, 0.015, 0.293, 0.017 Preview of result: "when q=false, nmax= 9830935647.0" ... ========================= @@ -271,11 +271,11 @@ Performance tests for RemesPath (references to compile-time constant variables) Compiling query "var X = X; var onetwo = j`[1, 2]`; -@[:]->at(@, X)->at(@, onetwo)" took 0.366 ms the first time, including approximately 0.105 ms to tokenize the query. Subsequent executions are effectively free due to caching. +@[:]->at(@, X)->at(@, onetwo)" took 0.074 ms the first time, including approximately 0.078 ms to tokenize the query. Subsequent executions are effectively free due to caching. To run pre-compiled query "var X = X; var onetwo = j`[1, 2]`; -@[:]->at(@, X)->at(@, onetwo)" on JNode from JSON of size 89556 into took 0.017 +/- 0.01 ms over 40 trials -Query times (ms): 0.064, 0.013, 0.012, 0.013, 0.023, 0.012, 0.013, 0.012, 0.012, 0.013, 0.013, 0.014, 0.012, 0.013, 0.016, 0.032, 0.013, 0.013, 0.039, 0.029, 0.024, 0.023, 0.021, 0.022, 0.021, 0.021, 0.014, 0.013, 0.012, 0.012, 0.012, 0.012, 0.012, 0.012, 0.012, 0.013, 0.012, 0.012, 0.012, 0.012 +@[:]->at(@, X)->at(@, onetwo)" on JNode from JSON of size 89556 into took 0.013 +/- 0.006 ms over 40 trials +Query times (ms): 0.05, 0.013, 0.012, 0.012, 0.017, 0.012, 0.012, 0.012, 0.012, 0.011, 0.012, 0.012, 0.012, 0.012, 0.012, 0.012, 0.012, 0.012, 0.012, 0.012, 0.012, 0.012, 0.012, 0.012, 0.013, 0.012, 0.012, 0.012, 0.012, 0.013, 0.012, 0.012, 0.012, 0.012, 0.012, 0.012, 0.012, 0.012, 0.012, 0.012 Preview of result: [[1695727848, 0.28756263873668497], [2126430375, 0.0076779412970817704], [5310550656, 0.38076977264568701], [2519183283, 0.15317622093055799], [6610062385, 0.66299622587066598], [987168256, 0.92441018999992797], [6615003609, 0.91711269122594696], [4465232046, 0.68431193185153605], [8654414565, 0.631 ... ========================= @@ -284,29 +284,29 @@ Performance tests for RemesPath (references to variables that are not compile-ti Compiling query "var X = @->`X`; var onetwo = @{1, 2}; -@[:]->at(@, X)->at(@, onetwo)" took 0.128 ms the first time, including approximately 0.153 ms to tokenize the query. Subsequent executions are effectively free due to caching. +@[:]->at(@, X)->at(@, onetwo)" took 0.104 ms the first time, including approximately 0.168 ms to tokenize the query. Subsequent executions are effectively free due to caching. To run pre-compiled query "var X = @->`X`; var onetwo = @{1, 2}; -@[:]->at(@, X)->at(@, onetwo)" on JNode from JSON of size 89556 into took 0.026 +/- 0.013 ms over 40 trials -Query times (ms): 0.084, 0.021, 0.03, 0.034, 0.031, 0.022, 0.039, 0.018, 0.016, 0.047, 0.017, 0.016, 0.018, 0.018, 0.016, 0.017, 0.018, 0.017, 0.017, 0.017, 0.016, 0.016, 0.017, 0.016, 0.018, 0.018, 0.026, 0.031, 0.049, 0.033, 0.027, 0.032, 0.03, 0.033, 0.031, 0.028, 0.027, 0.029, 0.027, 0.028 +@[:]->at(@, X)->at(@, onetwo)" on JNode from JSON of size 89556 into took 0.021 +/- 0.017 ms over 40 trials +Query times (ms): 0.114, 0.016, 0.023, 0.016, 0.015, 0.016, 0.027, 0.015, 0.016, 0.016, 0.015, 0.016, 0.017, 0.053, 0.016, 0.016, 0.022, 0.024, 0.05, 0.015, 0.015, 0.025, 0.016, 0.016, 0.016, 0.015, 0.016, 0.016, 0.016, 0.015, 0.016, 0.015, 0.016, 0.016, 0.015, 0.015, 0.016, 0.015, 0.016, 0.016 Preview of result: [[1695727848, 0.28756263873668497], [2126430375, 0.0076779412970817704], [5310550656, 0.38076977264568701], [2519183283, 0.15317622093055799], [6610062385, 0.66299622587066598], [987168256, 0.92441018999992797], [6615003609, 0.91711269122594696], [4465232046, 0.68431193185153605], [8654414565, 0.631 ... ========================= Performance tests for RemesPath (simple string mutations) ========================= -Compiling query "@[:].z = s_sub(@, g, B)" took 0.084 ms the first time, including approximately 0.09 ms to tokenize the query. Subsequent executions are effectively free due to caching. -To run pre-compiled query "@[:].z = s_sub(@, g, B)" on JNode from JSON of size 89556 into took 0.028 +/- 0.008 ms over 40 trials -Query times (ms): 0.045, 0.04, 0.014, 0.012, 0.019, 0.031, 0.028, 0.043, 0.038, 0.036, 0.022, 0.032, 0.032, 0.037, 0.026, 0.039, 0.022, 0.022, 0.021, 0.022, 0.012, 0.023, 0.025, 0.036, 0.041, 0.018, 0.027, 0.032, 0.039, 0.023, 0.021, 0.026, 0.021, 0.02, 0.021, 0.023, 0.023, 0.027, 0.036, 0.029 +Compiling query "@[:].z = s_sub(@, g, B)" took 0.048 ms the first time, including approximately 0.049 ms to tokenize the query. Subsequent executions are effectively free due to caching. +To run pre-compiled query "@[:].z = s_sub(@, g, B)" on JNode from JSON of size 89556 into took 0.013 +/- 0.004 ms over 40 trials +Query times (ms): 0.027, 0.015, 0.012, 0.009, 0.009, 0.011, 0.015, 0.015, 0.02, 0.017, 0.015, 0.015, 0.014, 0.013, 0.025, 0.013, 0.01, 0.01, 0.01, 0.011, 0.01, 0.011, 0.01, 0.011, 0.009, 0.012, 0.013, 0.015, 0.016, 0.013, 0.01, 0.01, 0.012, 0.012, 0.011, 0.012, 0.011, 0.011, 0.011, 0.009 Preview of result: [{"A": "Ky'c^g#~)0", "a": 1850111954, "b": 9318359041, "B": "Oyi:/ xxe2", "C": "sKCSa_^7Gg", "c": 7974777124, "d": 2670309238, "D": "0d_K)HmX!.", "E": ".uM*Z{0EJ_", "e": 6958410336, "f": 8050244728, "F": "1%SG_A!xB\t", "g": 3799657125, "G": "il1^k\\\nat*", "H": {"a": 6079042826, "b": 7292804611, "c" ... ========================= Performance tests for RemesPath (simple number mutations) ========================= -Compiling query "@[:].x = ifelse(@ < 0.5, @ + 3, @ - 3)" took 0.125 ms the first time, including approximately 0.133 ms to tokenize the query. Subsequent executions are effectively free due to caching. -To run pre-compiled query "@[:].x = ifelse(@ < 0.5, @ + 3, @ - 3)" on JNode from JSON of size 89556 into took 0.029 +/- 0.008 ms over 40 trials -Query times (ms): 0.044, 0.023, 0.021, 0.02, 0.021, 0.032, 0.021, 0.025, 0.021, 0.024, 0.046, 0.029, 0.022, 0.026, 0.037, 0.034, 0.02, 0.02, 0.022, 0.026, 0.02, 0.02, 0.02, 0.025, 0.023, 0.021, 0.031, 0.052, 0.036, 0.032, 0.031, 0.037, 0.037, 0.032, 0.032, 0.03, 0.032, 0.034, 0.032, 0.032 +Compiling query "@[:].x = ifelse(@ < 0.5, @ + 3, @ - 3)" took 0.084 ms the first time, including approximately 0.114 ms to tokenize the query. Subsequent executions are effectively free due to caching. +To run pre-compiled query "@[:].x = ifelse(@ < 0.5, @ + 3, @ - 3)" on JNode from JSON of size 89556 into took 0.023 +/- 0.01 ms over 40 trials +Query times (ms): 0.035, 0.019, 0.018, 0.018, 0.019, 0.018, 0.018, 0.019, 0.018, 0.018, 0.019, 0.019, 0.075, 0.033, 0.02, 0.019, 0.019, 0.02, 0.021, 0.022, 0.038, 0.022, 0.019, 0.022, 0.023, 0.025, 0.024, 0.025, 0.019, 0.018, 0.024, 0.026, 0.019, 0.023, 0.02, 0.019, 0.018, 0.019, 0.019, 0.025 Preview of result: [{"A": "Ky'c^g#~)0", "a": 1850111954, "b": 9318359041, "B": "Oyi:/ xxe2", "C": "sKCSa_^7Gg", "c": 7974777124, "d": 2670309238, "D": "0d_K)HmX!.", "E": ".uM*Z{0EJ_", "e": 6958410336, "f": 8050244728, "F": "1%SG_A!xB\t", "g": 3799657125, "G": "il1^k\\\nat*", "H": {"a": 6079042826, "b": 7292804611, "c" ... ========================= @@ -316,12 +316,12 @@ Performance tests for RemesPath (mutations with a for loop) Compiling query "var xhalf = @[:].x < 0.5; for lx = zip(@[:].l, xhalf); lx[0] = ifelse(lx[1], foo, bar); -end for;" took 0.201 ms the first time, including approximately 0.158 ms to tokenize the query. Subsequent executions are effectively free due to caching. +end for;" took 0.164 ms the first time, including approximately 0.109 ms to tokenize the query. Subsequent executions are effectively free due to caching. To run pre-compiled query "var xhalf = @[:].x < 0.5; for lx = zip(@[:].l, xhalf); lx[0] = ifelse(lx[1], foo, bar); -end for;" on JNode from JSON of size 89556 into took 0.069 +/- 0.035 ms over 40 trials -Query times (ms): 0.087, 0.056, 0.046, 0.06, 0.041, 0.051, 0.048, 0.052, 0.049, 0.057, 0.064, 0.08, 0.075, 0.056, 0.057, 0.06, 0.107, 0.093, 0.238, 0.058, 0.074, 0.042, 0.044, 0.066, 0.092, 0.044, 0.04, 0.042, 0.04, 0.042, 0.042, 0.102, 0.05, 0.051, 0.074, 0.102, 0.148, 0.074, 0.072, 0.071 +end for;" on JNode from JSON of size 89556 into took 0.044 +/- 0.019 ms over 40 trials +Query times (ms): 0.097, 0.04, 0.04, 0.038, 0.038, 0.038, 0.037, 0.039, 0.037, 0.058, 0.133, 0.079, 0.039, 0.036, 0.036, 0.036, 0.036, 0.035, 0.035, 0.036, 0.05, 0.036, 0.034, 0.049, 0.042, 0.036, 0.035, 0.035, 0.036, 0.035, 0.035, 0.037, 0.038, 0.038, 0.036, 0.057, 0.041, 0.037, 0.039, 0.037 Preview of result: [["bar", false], ["bar", false], ["foo", true], ["foo", true], ["foo", true], ["foo", true], ["foo", true], ["bar", false], ["bar", false], ["bar", false], ["foo", true], ["foo", true], ["bar", false], ["bar", false], ["foo", true], ["bar", false], ["bar", false], ["bar", false], ["foo", true], ["ba ... ========================= @@ -330,32 +330,32 @@ Testing performance of JSON compression and pretty-printing Preview of json: [{"A": "Ky'c^g#~)0", "a": 1850111954, "b": 9318359041, "B": "Oyi:/ xxe2", "C": "sKCSa_^7Gg", "c": 7974777124, "d": 2670309238, "D": "0d_K)HmX!.", "E": ".uM*Z{0EJ_", "e": 6958410336, "f": 8050244728, "F": "1%SG_A!xB\t", "g": 3799657125, "G": "il1^k\\\nat*", "H": {"a": 6079042826, "b": 7292804611, "c" ... -To compress JNode from JSON string of 89556 took 4.809 +/- 0.834 ms over 64 trials (minimal whitespace, sortKeys=TRUE) -To compress JNode from JSON string of 89556 took 2.423 +/- 0.391 ms over 64 trials (minimal whitespace, sortKeys=FALSE) -To Google-style pretty-print JNode from JSON string of 89556 took 4.677 +/- 0.676 ms over 64 trials (sortKeys=true, indent=4) -To Whitesmith-style pretty-print JNode from JSON string of 89556 took 4.376 +/- 0.389 ms over 64 trials (sortKeys=true, indent=4) -To PPrint-style pretty-print JNode from JSON string of 89556 took 6.201 +/- 0.675 ms over 64 trials (sortKeys=true, indent=4) +To compress JNode from JSON string of 89556 took 4.404 +/- 1.087 ms over 64 trials (minimal whitespace, sortKeys=TRUE) +To compress JNode from JSON string of 89556 took 2.481 +/- 0.335 ms over 64 trials (minimal whitespace, sortKeys=FALSE) +To Google-style pretty-print JNode from JSON string of 89556 took 4.836 +/- 0.491 ms over 64 trials (sortKeys=true, indent=4) +To Whitesmith-style pretty-print JNode from JSON string of 89556 took 4.591 +/- 0.862 ms over 64 trials (sortKeys=true, indent=4) +To PPrint-style pretty-print JNode from JSON string of 89556 took 6.066 +/- 0.637 ms over 64 trials (sortKeys=true, indent=4) ========================= Testing performance of JsonSchemaValidator and random JSON creation ========================= -To create a random set of JSON from file at path C:\Program Files\Notepad++\plugins\JsonTools\testfiles\tweet_schema.json of size 191540 (array of 15 items) based on the matching schema took 6.908 +/- 3.313 ms over 25 trials -To compile the schema to a validation function took 0.212 +/- 0.022 ms over 25 trials -To validate JSON of size 191540 (array of 15 items) based on the compiled schema took 1.03 +/- 0.196 ms over 25 trials +To create a random set of JSON from file at path C:\Program Files\Notepad++\plugins\JsonTools\testfiles\tweet_schema.json of size 184326 (array of 15 items) based on the matching schema took 6.595 +/- 2.757 ms over 25 trials +To compile the schema to a validation function took 0.33 +/- 0.544 ms over 25 trials +To validate JSON of size 184326 (array of 15 items) based on the compiled schema took 1.051 +/- 0.2 ms over 25 trials ========================= Testing performance of random JSON from schema with patterns and patternProperties ========================= -To create a random set of JSON from string (see TestRunner.cs) of size 27104 (array of 120 items) based on the matching schema took 1.621 +/- 0.903 ms over 25 trials -To compile the schema to a validation function took 0.268 +/- 0.029 ms over 25 trials -To validate JSON of size 27104 (array of 120 items) based on the compiled schema took 9.526 +/- 0.871 ms over 25 trials +To create a random set of JSON from string (see TestRunner.cs) of size 29841 (array of 120 items) based on the matching schema took 1.438 +/- 0.669 ms over 25 trials +To compile the schema to a validation function took 0.348 +/- 0.508 ms over 25 trials +To validate JSON of size 29841 (array of 120 items) based on the compiled schema took 8.877 +/- 0.255 ms over 25 trials ========================= Testing performance of random JSON from schema *ignoring* patterns and patternProperties ========================= -To create a random set of JSON from string (see TestRunner.cs) of size 10690 (array of 120 items) based on the matching schema took 0.804 +/- 0.443 ms over 25 trials -To compile the schema to a validation function took 0.318 +/- 0.379 ms over 25 trials -To validate JSON of size 10690 (array of 120 items) based on the compiled schema took 5.515 +/- 0.22 ms over 25 trials +To create a random set of JSON from string (see TestRunner.cs) of size 10853 (array of 120 items) based on the matching schema took 0.831 +/- 0.516 ms over 25 trials +To compile the schema to a validation function took 0.21 +/- 0.007 ms over 25 trials +To validate JSON of size 10853 (array of 120 items) based on the compiled schema took 5.334 +/- 0.223 ms over 25 trials ========================= Testing JSON grepper's API request tool =========================