1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
SELECT json_get('{"key": "value", "key2": "value2"}', 'key');
json_get
----------
"value"
(1 row)
SELECT json_get('{"key": "value", "key": "value2"}', 'key');
ERROR: JSONPath expression matched multiple results
/* These each return no result because 0 is a number
(indicating a numeric subscript),
not a string (indicating an object subscript). */
SELECT json_get('{"0": "value", "key": "value"}', '0');
json_get
----------
(1 row)
SELECT json_get('{"0": "value", "0": "value"}', '[0]');
json_get
----------
(1 row)
SELECT json_get('{"0": "value", "0": "value"}', '.0');
json_get
----------
(1 row)
SELECT json_get('{"0": "value", "1": "value"}', '["0"]');
json_get
----------
"value"
(1 row)
SELECT json_get('{"0": "value", "0": "value"}', '["0"]');
ERROR: JSONPath expression matched multiple results
SELECT json_get('[0,1,2,3]', '0');
json_get
----------
0
(1 row)
SELECT json_get('[0,1,2,3]', '"0"');
json_get
----------
(1 row)
SELECT json_get('[0,1,2,3]', '*');
ERROR: JSONPath expression matched multiple results
SELECT json_get('[0]', '*');
json_get
----------
0
(1 row)
SELECT json_get('[[0]]', '..*');
ERROR: JSONPath expression matched multiple results
|