When there are multiple attributes in a JSON object with the same name, which is allowed but discouraged in JSON, JSON_KEYS returns one entry for each duplicate:
MySQL [test]> select JSON_KEYS('{"c1": "value 1", "c1": "value 2"}');
|
+-------------------------------------------------+
|
| JSON_KEYS('{"c1": "value 1", "c1": "value 2"}') |
|
+-------------------------------------------------+
|
| ["c1", "c1"] |
|
+-------------------------------------------------+
|
MySQL 5.7 returns just the single key:
MySQL [test]> select JSON_KEYS('{"c1": "value 1", "c1": "value 2"}');
|
+-------------------------------------------------+
|
| JSON_KEYS('{"c1": "value 1", "c1": "value 2"}') |
|
+-------------------------------------------------+
|
| ["c1"] |
|
+-------------------------------------------------+
|
Multiple values for a single key are discouraged, but I think MySQL has the correct behavior as the JSON_KEYS function should return an array of the keys, and although "c1" in the example above exists twice in the object, it is the same key.
{"report":{"fcp":683.2000007629395,"ttfb":153.20000076293945,"pageVisibility":"visible","entityId":61341,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":1,"journeyId":"b1487e80-f9fd-483b-9b51-84b306896d73","navigationType":0,"readyForUser":739.3000001907349,"redirectCount":0,"resourceLoadedEnd":775.7000007629395,"resourceLoadedStart":158,"resourceTiming":[{"duration":7.40000057220459,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":158,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":158,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":165.4000005722046,"responseStart":0,"secureConnectionStart":0},{"duration":7.399999618530273,"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":158.20000076293945,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":158.20000076293945,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":165.60000038146973,"responseStart":0,"secureConnectionStart":0},{"duration":63.30000019073486,"initiatorType":"script","name":"https://jira.mariadb.org/s/fbf975c0cce4b1abf04784eeae9ba1f4-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":158.30000019073486,"connectEnd":158.30000019073486,"connectStart":158.30000019073486,"domainLookupEnd":158.30000019073486,"domainLookupStart":158.30000019073486,"fetchStart":158.30000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":158.30000019073486,"responseEnd":221.60000038146973,"responseStart":221.60000038146973,"secureConnectionStart":158.30000019073486},{"duration":136.80000019073486,"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":158.4000005722046,"connectEnd":158.4000005722046,"connectStart":158.4000005722046,"domainLookupEnd":158.4000005722046,"domainLookupStart":158.4000005722046,"fetchStart":158.4000005722046,"redirectEnd":0,"redirectStart":0,"requestStart":158.4000005722046,"responseEnd":295.20000076293945,"responseStart":295.20000076293945,"secureConnectionStart":158.4000005722046},{"duration":140.20000076293945,"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":158.5,"connectEnd":158.5,"connectStart":158.5,"domainLookupEnd":158.5,"domainLookupStart":158.5,"fetchStart":158.5,"redirectEnd":0,"redirectStart":0,"requestStart":158.5,"responseEnd":298.70000076293945,"responseStart":298.70000076293945,"secureConnectionStart":158.5},{"duration":140.5,"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":158.60000038146973,"connectEnd":158.60000038146973,"connectStart":158.60000038146973,"domainLookupEnd":158.60000038146973,"domainLookupStart":158.60000038146973,"fetchStart":158.60000038146973,"redirectEnd":0,"redirectStart":0,"requestStart":158.60000038146973,"responseEnd":299.1000003814697,"responseStart":299.1000003814697,"secureConnectionStart":158.60000038146973},{"duration":140.79999923706055,"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":158.70000076293945,"connectEnd":158.70000076293945,"connectStart":158.70000076293945,"domainLookupEnd":158.70000076293945,"domainLookupStart":158.70000076293945,"fetchStart":158.70000076293945,"redirectEnd":0,"redirectStart":0,"requestStart":158.70000076293945,"responseEnd":299.5,"responseStart":299.5,"secureConnectionStart":158.70000076293945},{"duration":141.60000038146973,"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":158.80000019073486,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":158.80000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":300.4000005722046,"responseStart":0,"secureConnectionStart":0},{"duration":141,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":158.80000019073486,"connectEnd":158.80000019073486,"connectStart":158.80000019073486,"domainLookupEnd":158.80000019073486,"domainLookupStart":158.80000019073486,"fetchStart":158.80000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":158.80000019073486,"responseEnd":299.80000019073486,"responseStart":299.80000019073486,"secureConnectionStart":158.80000019073486},{"duration":141.70000076293945,"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":159,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":159,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":300.70000076293945,"responseStart":0,"secureConnectionStart":0},{"duration":141.19999980926514,"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":159.10000038146973,"connectEnd":159.10000038146973,"connectStart":159.10000038146973,"domainLookupEnd":159.10000038146973,"domainLookupStart":159.10000038146973,"fetchStart":159.10000038146973,"redirectEnd":0,"redirectStart":0,"requestStart":159.10000038146973,"responseEnd":300.30000019073486,"responseStart":300.30000019073486,"secureConnectionStart":159.10000038146973},{"duration":391.80000019073486,"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":164.9000005722046,"connectEnd":164.9000005722046,"connectStart":164.9000005722046,"domainLookupEnd":164.9000005722046,"domainLookupStart":164.9000005722046,"fetchStart":164.9000005722046,"redirectEnd":0,"redirectStart":0,"requestStart":164.9000005722046,"responseEnd":556.7000007629395,"responseStart":556.7000007629395,"secureConnectionStart":164.9000005722046},{"duration":413,"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":165,"connectEnd":165,"connectStart":165,"domainLookupEnd":165,"domainLookupStart":165,"fetchStart":165,"redirectEnd":0,"redirectStart":0,"requestStart":165,"responseEnd":578,"responseStart":578,"secureConnectionStart":165},{"duration":133,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":436,"connectEnd":436,"connectStart":436,"domainLookupEnd":436,"domainLookupStart":436,"fetchStart":436,"redirectEnd":0,"redirectStart":0,"requestStart":436,"responseEnd":569,"responseStart":569,"secureConnectionStart":436},{"duration":144.70000076293945,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/e65b778d185daf5aee24936755b43da6/_/download/contextbatch/js/browser-metrics-plugin.contrib,-_super,-project.issue.navigator,-jira.view.issue,-atl.general/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true","startTime":631,"connectEnd":631,"connectStart":631,"domainLookupEnd":631,"domainLookupStart":631,"fetchStart":631,"redirectEnd":0,"redirectStart":0,"requestStart":631,"responseEnd":775.7000007629395,"responseStart":775.7000007629395,"secureConnectionStart":631},{"duration":116.30000019073486,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":660.3000001907349,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":660.3000001907349,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":776.6000003814697,"responseStart":0,"secureConnectionStart":0}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":11,"responseStart":153,"responseEnd":164,"domLoading":156,"domInteractive":806,"domContentLoadedEventStart":806,"domContentLoadedEventEnd":846,"domComplete":1096,"loadEventStart":1096,"loadEventEnd":1097,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":771.5},{"name":"bigPipe.sidebar-id.end","time":772.4000005722046},{"name":"bigPipe.activity-panel-pipe-id.start","time":772.5},{"name":"bigPipe.activity-panel-pipe-id.end","time":775.5},{"name":"activityTabFullyLoaded","time":863.1000003814697}],"measures":[],"correlationId":"f66def9e43223d","effectiveType":"4g","downlink":9.6,"rtt":0,"serverDuration":85,"dbReadsTimeInMs":14,"dbConnsTimeInMs":23,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}
But should JSON_KEYS return keys or unique keys, according to the standard? If it's just keys, and while duplicate keys are only discouraged but not prohibited, MariaDB behavior seems justified – there are indeed two keys "c1", so it returns two.