@@ -42,36 +42,7 @@ LINE 1: SELECT '"\v"'::json;
42
42
^
43
43
DETAIL: Escape sequence "\v" is invalid.
44
44
CONTEXT: JSON data, line 1: "\v...
45
- SELECT '"\u"'::json; -- ERROR, incomplete escape
46
- ERROR: invalid input syntax for type json
47
- LINE 1: SELECT '"\u"'::json;
48
- ^
49
- DETAIL: "\u" must be followed by four hexadecimal digits.
50
- CONTEXT: JSON data, line 1: "\u"
51
- SELECT '"\u00"'::json; -- ERROR, incomplete escape
52
- ERROR: invalid input syntax for type json
53
- LINE 1: SELECT '"\u00"'::json;
54
- ^
55
- DETAIL: "\u" must be followed by four hexadecimal digits.
56
- CONTEXT: JSON data, line 1: "\u00"
57
- SELECT '"\u000g"'::json; -- ERROR, g is not a hex digit
58
- ERROR: invalid input syntax for type json
59
- LINE 1: SELECT '"\u000g"'::json;
60
- ^
61
- DETAIL: "\u" must be followed by four hexadecimal digits.
62
- CONTEXT: JSON data, line 1: "\u000g...
63
- SELECT '"\u0000"'::json; -- OK, legal escape
64
- json
65
- ----------
66
- "\u0000"
67
- (1 row)
68
-
69
- SELECT '"\uaBcD"'::json; -- OK, uppercase and lower case both OK
70
- json
71
- ----------
72
- "\uaBcD"
73
- (1 row)
74
-
45
+ -- see json_encoding test for input with unicode escapes
75
46
-- Numbers.
76
47
SELECT '1'::json; -- OK
77
48
json
@@ -1395,88 +1366,6 @@ select * from json_populate_recordset(row('def',99,null)::jpop,'[{"a":[100,200,3
1395
1366
{"z":true} | 3 | Fri Jan 20 10:42:53 2012
1396
1367
(2 rows)
1397
1368
1398
- -- handling of unicode surrogate pairs
1399
- select json '{ "a": "\ud83d\ude04\ud83d\udc36" }' -> 'a' as correct_in_utf8;
1400
- correct_in_utf8
1401
- ----------------------------
1402
- "\ud83d\ude04\ud83d\udc36"
1403
- (1 row)
1404
-
1405
- select json '{ "a": "\ud83d\ud83d" }' -> 'a'; -- 2 high surrogates in a row
1406
- ERROR: invalid input syntax for type json
1407
- DETAIL: Unicode high surrogate must not follow a high surrogate.
1408
- CONTEXT: JSON data, line 1: { "a":...
1409
- select json '{ "a": "\ude04\ud83d" }' -> 'a'; -- surrogates in wrong order
1410
- ERROR: invalid input syntax for type json
1411
- DETAIL: Unicode low surrogate must follow a high surrogate.
1412
- CONTEXT: JSON data, line 1: { "a":...
1413
- select json '{ "a": "\ud83dX" }' -> 'a'; -- orphan high surrogate
1414
- ERROR: invalid input syntax for type json
1415
- DETAIL: Unicode low surrogate must follow a high surrogate.
1416
- CONTEXT: JSON data, line 1: { "a":...
1417
- select json '{ "a": "\ude04X" }' -> 'a'; -- orphan low surrogate
1418
- ERROR: invalid input syntax for type json
1419
- DETAIL: Unicode low surrogate must follow a high surrogate.
1420
- CONTEXT: JSON data, line 1: { "a":...
1421
- --handling of simple unicode escapes
1422
- select json '{ "a": "the Copyright \u00a9 sign" }' as correct_in_utf8;
1423
- correct_in_utf8
1424
- ---------------------------------------
1425
- { "a": "the Copyright \u00a9 sign" }
1426
- (1 row)
1427
-
1428
- select json '{ "a": "dollar \u0024 character" }' as correct_everywhere;
1429
- correct_everywhere
1430
- -------------------------------------
1431
- { "a": "dollar \u0024 character" }
1432
- (1 row)
1433
-
1434
- select json '{ "a": "dollar \\u0024 character" }' as not_an_escape;
1435
- not_an_escape
1436
- --------------------------------------
1437
- { "a": "dollar \\u0024 character" }
1438
- (1 row)
1439
-
1440
- select json '{ "a": "null \u0000 escape" }' as not_unescaped;
1441
- not_unescaped
1442
- --------------------------------
1443
- { "a": "null \u0000 escape" }
1444
- (1 row)
1445
-
1446
- select json '{ "a": "null \\u0000 escape" }' as not_an_escape;
1447
- not_an_escape
1448
- ---------------------------------
1449
- { "a": "null \\u0000 escape" }
1450
- (1 row)
1451
-
1452
- select json '{ "a": "the Copyright \u00a9 sign" }' ->> 'a' as correct_in_utf8;
1453
- correct_in_utf8
1454
- ----------------------
1455
- the Copyright © sign
1456
- (1 row)
1457
-
1458
- select json '{ "a": "dollar \u0024 character" }' ->> 'a' as correct_everywhere;
1459
- correct_everywhere
1460
- --------------------
1461
- dollar $ character
1462
- (1 row)
1463
-
1464
- select json '{ "a": "dollar \\u0024 character" }' ->> 'a' as not_an_escape;
1465
- not_an_escape
1466
- -------------------------
1467
- dollar \u0024 character
1468
- (1 row)
1469
-
1470
- select json '{ "a": "null \u0000 escape" }' ->> 'a' as fails;
1471
- ERROR: unsupported Unicode escape sequence
1472
- DETAIL: \u0000 cannot be converted to text.
1473
- CONTEXT: JSON data, line 1: { "a":...
1474
- select json '{ "a": "null \\u0000 escape" }' ->> 'a' as not_an_escape;
1475
- not_an_escape
1476
- --------------------
1477
- null \u0000 escape
1478
- (1 row)
1479
-
1480
1369
--json_typeof() function
1481
1370
select value, json_typeof(value)
1482
1371
from (values (json '123.4'),
0 commit comments