1379
1365
-- handling of unicode surrogate pairs
1380
1366
select json '{ "a": "\ud83d\ude04\ud83d\udc36" }' -> 'a' as correct_in_utf8;
1381
ERROR: invalid input syntax for type json
1367
ERROR: unsupported Unicode escape sequence
1382
1368
DETAIL: Unicode escape values cannot be used for code point values above 007F when the server encoding is not UTF8.
1383
1369
CONTEXT: JSON data, line 1: { "a":...
1384
1370
select json '{ "a": "\ud83d\ud83d" }' -> 'a'; -- 2 high surrogates in a row
1398
1384
DETAIL: Unicode low surrogate must follow a high surrogate.
1399
1385
CONTEXT: JSON data, line 1: { "a":...
1400
1386
--handling of simple unicode escapes
1387
select json '{ "a": "the Copyright \u00a9 sign" }' as correct_in_utf8;
1389
---------------------------------------
1390
{ "a": "the Copyright \u00a9 sign" }
1393
select json '{ "a": "dollar \u0024 character" }' as correct_everywhere;
1395
-------------------------------------
1396
{ "a": "dollar \u0024 character" }
1399
select json '{ "a": "dollar \\u0024 character" }' as not_an_escape;
1401
--------------------------------------
1402
{ "a": "dollar \\u0024 character" }
1405
select json '{ "a": "null \u0000 escape" }' as not_unescaped;
1407
--------------------------------
1408
{ "a": "null \u0000 escape" }
1411
select json '{ "a": "null \\u0000 escape" }' as not_an_escape;
1413
---------------------------------
1414
{ "a": "null \\u0000 escape" }
1401
1417
select json '{ "a": "the Copyright \u00a9 sign" }' ->> 'a' as correct_in_utf8;
1402
ERROR: invalid input syntax for type json
1418
ERROR: unsupported Unicode escape sequence
1403
1419
DETAIL: Unicode escape values cannot be used for code point values above 007F when the server encoding is not UTF8.
1404
1420
CONTEXT: JSON data, line 1: { "a":...
1405
1421
select json '{ "a": "dollar \u0024 character" }' ->> 'a' as correct_everywhere;
1408
1424
dollar $ character
1411
select json '{ "a": "null \u0000 escape" }' ->> 'a' as not_unescaped;
1427
select json '{ "a": "dollar \\u0024 character" }' ->> 'a' as not_an_escape;
1429
-------------------------
1430
dollar \u0024 character
1433
select json '{ "a": "null \u0000 escape" }' ->> 'a' as fails;
1434
ERROR: unsupported Unicode escape sequence
1435
DETAIL: \u0000 cannot be converted to text.
1436
CONTEXT: JSON data, line 1: { "a":...
1437
select json '{ "a": "null \\u0000 escape" }' ->> 'a' as not_an_escape;
1413
1439
--------------------
1414
1440
null \u0000 escape