Test:
SET @json1= '[
|
[{"key1": "value1"}, {"key2": "value2"}],
|
[{"key3": "value3"}, {"key1": "value4"}],
|
[{"key1": "value5"}, {"key4": "value6"}, {"key1": "value7"}]
|
]';
|
SELECT JSON_VALUE(@json1, '$[2][1 to 2].key1');
|
SELECT JSON_VALUE(@json1, '$[2][1].key1');
|
SELECT JSON_VALUE(@json1, '$[2][2].key1');
|
Expected result:
SET @json1= '[
|
[{"key1": "value1"}, {"key2": "value2"}],
|
[{"key3": "value3"}, {"key1": "value4"}],
|
[{"key1": "value5"}, {"key4": "value6"}, {"key1": "value7"}]
|
]';
|
SELECT JSON_VALUE(@json1, '$[2][1 to 2].key1');
|
JSON_VALUE(@json1, '$[2][1 to 2].key1')
|
value7
|
SELECT JSON_VALUE(@json1, '$[2][1].key1');
|
JSON_VALUE(@json1, '$[2][1].key1')
|
NULL
|
SELECT JSON_VALUE(@json1, '$[2][2].key1');
|
JSON_VALUE(@json1, '$[2][2].key1')
|
value7
|
Actual result:
SET @json1= '[
|
[{"key1": "value1"}, {"key2": "value2"}],
|
[{"key3": "value3"}, {"key1": "value4"}],
|
[{"key1": "value5"}, {"key4": "value6"}, {"key1": "value7"}]
|
]';
|
SELECT JSON_VALUE(@json1, '$[2][1 to 2].key1');
|
JSON_VALUE(@json1, '$[2][1 to 2].key1')
|
value5
|
SELECT JSON_VALUE(@json1, '$[2][1].key1');
|
JSON_VALUE(@json1, '$[2][1].key1')
|
NULL
|
SELECT JSON_VALUE(@json1, '$[2][2].key1');
|
JSON_VALUE(@json1, '$[2][2].key1')
|
value7
|
The same behavior when json contains only arrays:
SET @json= '[
|
[1.1, {"key1": "value1"}, 3],
|
[false, 5, 6],
|
[7, 8, [9, {"key2": 2}, 11]],
|
[11, 1.34, [14], ["string1", [16, {"key1":[1,2,3,[4,5,6]]}, 18]]],
|
[19, 20]
|
]';
|
SELECT JSON_VALUE(@json, '$[2 to 3][0]');
|
JSON_VALUE(@json, '$[2 to 3][0]')
|
1.1
|
SELECT JSON_VALUE(@json, '$[2][0]');
|
JSON_VALUE(@json, '$[2][0]')
|
7
|
SELECT JSON_VALUE(@json, '$[3][0]');
|
JSON_VALUE(@json, '$[3][0]')
|
11
|
"1.1" is the first value in array not first in the specified range.
- relates to
-
MDEV-27911
Implement range notation for json path
-
-
Closed
{"report":{"fcp":768.1000001430511,"ttfb":138.90000009536743,"pageVisibility":"visible","entityId":108849,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":1,"journeyId":"e1ad049a-34ea-4d0a-885e-3d5a5efcc74d","navigationType":0,"readyForUser":901.9000000953674,"redirectCount":0,"resourceLoadedEnd":956.2999999523163,"resourceLoadedStart":144.60000014305115,"resourceTiming":[{"duration":212.79999995231628,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":144.60000014305115,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":144.60000014305115,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":357.40000009536743,"responseStart":0,"secureConnectionStart":0},{"duration":212.5,"initiatorType":"link","name":"https://jira.mariadb.org/s/7ebd35e77e471bc30ff0eba799ebc151-CDN/lu2bu7/820016/12ta74/8679b4946efa1a0bb029a3a22206fb5d/_/download/contextbatch/css/jira.browse.project,project.issue.navigator,jira.view.issue,jira.general,jira.global,atl.general,-_super/batch.css?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true","startTime":144.90000009536743,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":144.90000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":357.40000009536743,"responseStart":0,"secureConnectionStart":0},{"duration":222.10000014305115,"initiatorType":"script","name":"https://jira.mariadb.org/s/fbf975c0cce4b1abf04784eeae9ba1f4-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":145,"connectEnd":145,"connectStart":145,"domainLookupEnd":145,"domainLookupStart":145,"fetchStart":145,"redirectEnd":0,"redirectStart":0,"requestStart":145,"responseEnd":367.10000014305115,"responseStart":367.10000014305115,"secureConnectionStart":145},{"duration":307.2999999523163,"initiatorType":"script","name":"https://jira.mariadb.org/s/94c15bff32baef80f4096a08aceae8bc-CDN/lu2bu7/820016/12ta74/c92c0caa9a024ae85b0ebdbed7fb4bd7/_/download/contextbatch/js/atl.global,-_super/batch.js?locale=en","startTime":145.20000004768372,"connectEnd":145.20000004768372,"connectStart":145.20000004768372,"domainLookupEnd":145.20000004768372,"domainLookupStart":145.20000004768372,"fetchStart":145.20000004768372,"redirectEnd":0,"redirectStart":0,"requestStart":145.20000004768372,"responseEnd":452.5,"responseStart":452.5,"secureConnectionStart":145.20000004768372},{"duration":303.7000000476837,"initiatorType":"script","name":"https://jira.mariadb.org/s/099b33461394b8015fc36c0a4b96e19f-CDN/lu2bu7/820016/12ta74/8679b4946efa1a0bb029a3a22206fb5d/_/download/contextbatch/js/jira.browse.project,project.issue.navigator,jira.view.issue,jira.general,jira.global,atl.general,-_super/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&locale=en&slack-enabled=true","startTime":145.20000004768372,"connectEnd":145.20000004768372,"connectStart":145.20000004768372,"domainLookupEnd":145.20000004768372,"domainLookupStart":145.20000004768372,"fetchStart":145.20000004768372,"redirectEnd":0,"redirectStart":0,"requestStart":145.20000004768372,"responseEnd":448.90000009536743,"responseStart":448.90000009536743,"secureConnectionStart":145.20000004768372},{"duration":307.7000000476837,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-en/jira.webresources:calendar-en.js","startTime":145.29999995231628,"connectEnd":145.29999995231628,"connectStart":145.29999995231628,"domainLookupEnd":145.29999995231628,"domainLookupStart":145.29999995231628,"fetchStart":145.29999995231628,"redirectEnd":0,"redirectStart":0,"requestStart":145.29999995231628,"responseEnd":453,"responseStart":453,"secureConnectionStart":145.29999995231628},{"duration":307.89999985694885,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-localisation-moment/jira.webresources:calendar-localisation-moment.js","startTime":145.40000009536743,"connectEnd":145.40000009536743,"connectStart":145.40000009536743,"domainLookupEnd":145.40000009536743,"domainLookupStart":145.40000009536743,"fetchStart":145.40000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":145.40000009536743,"responseEnd":453.2999999523163,"responseStart":453.2999999523163,"secureConnectionStart":145.40000009536743},{"duration":308.2000000476837,"initiatorType":"link","name":"https://jira.mariadb.org/s/b04b06a02d1959df322d9cded3aeecc1-CDN/lu2bu7/820016/12ta74/a2ff6aa845ffc9a1d22fe23d9ee791fc/_/download/contextbatch/css/jira.global.look-and-feel,-_super/batch.css","startTime":145.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":145.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":453.7000000476837,"responseStart":0,"secureConnectionStart":0},{"duration":308.19999980926514,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":145.60000014305115,"connectEnd":145.60000014305115,"connectStart":145.60000014305115,"domainLookupEnd":145.60000014305115,"domainLookupStart":145.60000014305115,"fetchStart":145.60000014305115,"redirectEnd":0,"redirectStart":0,"requestStart":145.60000014305115,"responseEnd":453.7999999523163,"responseStart":453.7999999523163,"secureConnectionStart":145.60000014305115},{"duration":308.40000009536743,"initiatorType":"link","name":"https://jira.mariadb.org/s/3ac36323ba5e4eb0af2aa7ac7211b4bb-CDN/lu2bu7/820016/12ta74/d176f0986478cc64f24226b3d20c140d/_/download/contextbatch/css/com.atlassian.jira.projects.sidebar.init,-_super,-project.issue.navigator,-jira.view.issue/batch.css?jira.create.linked.issue=true","startTime":145.79999995231628,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":145.79999995231628,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":454.2000000476837,"responseStart":0,"secureConnectionStart":0},{"duration":308.5,"initiatorType":"script","name":"https://jira.mariadb.org/s/3339d87fa2538a859872f2df449bf8d0-CDN/lu2bu7/820016/12ta74/d176f0986478cc64f24226b3d20c140d/_/download/contextbatch/js/com.atlassian.jira.projects.sidebar.init,-_super,-project.issue.navigator,-jira.view.issue/batch.js?jira.create.linked.issue=true&locale=en","startTime":145.90000009536743,"connectEnd":145.90000009536743,"connectStart":145.90000009536743,"domainLookupEnd":145.90000009536743,"domainLookupStart":145.90000009536743,"fetchStart":145.90000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":145.90000009536743,"responseEnd":454.40000009536743,"responseStart":454.40000009536743,"secureConnectionStart":145.90000009536743},{"duration":405.39999985694885,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-js/jira.webresources:bigpipe-js.js","startTime":146.60000014305115,"connectEnd":146.60000014305115,"connectStart":146.60000014305115,"domainLookupEnd":146.60000014305115,"domainLookupStart":146.60000014305115,"fetchStart":146.60000014305115,"redirectEnd":0,"redirectStart":0,"requestStart":146.60000014305115,"responseEnd":552,"responseStart":552,"secureConnectionStart":146.60000014305115},{"duration":809.5999999046326,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-init/jira.webresources:bigpipe-init.js","startTime":146.70000004768372,"connectEnd":146.70000004768372,"connectStart":146.70000004768372,"domainLookupEnd":146.70000004768372,"domainLookupStart":146.70000004768372,"fetchStart":146.70000004768372,"redirectEnd":0,"redirectStart":0,"requestStart":146.70000004768372,"responseEnd":956.2999999523163,"responseStart":956.2999999523163,"secureConnectionStart":146.70000004768372},{"duration":31.399999856948853,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":521.6000001430511,"connectEnd":521.6000001430511,"connectStart":521.6000001430511,"domainLookupEnd":521.6000001430511,"domainLookupStart":521.6000001430511,"fetchStart":521.6000001430511,"redirectEnd":0,"redirectStart":0,"requestStart":521.6000001430511,"responseEnd":553,"responseStart":553,"secureConnectionStart":521.6000001430511}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":11,"responseStart":139,"responseEnd":141,"domLoading":142,"domInteractive":973,"domContentLoadedEventStart":973,"domContentLoadedEventEnd":1019,"domComplete":1980,"loadEventStart":1980,"loadEventEnd":1981,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":958},{"name":"bigPipe.sidebar-id.end","time":958.9000000953674},{"name":"bigPipe.activity-panel-pipe-id.start","time":959.1000001430511},{"name":"bigPipe.activity-panel-pipe-id.end","time":961.6000001430511},{"name":"activityTabFullyLoaded","time":1032}],"measures":[],"correlationId":"92bb1b2f4840e9","effectiveType":"4g","downlink":9,"rtt":0,"serverDuration":72,"dbReadsTimeInMs":10,"dbConnsTimeInMs":17,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}