61
61
DETAIL: "\u" must be followed by four hexadecimal digits.
62
62
CONTEXT: JSON data, line 1: "\u000g...
63
SELECT '"\u0000"'::jsonb; -- OK, legal escape
63
SELECT '"\u0045"'::jsonb; -- OK, legal escape
69
SELECT '"\u0000"'::jsonb; -- ERROR, we don't support U+0000
70
ERROR: unsupported Unicode escape sequence
71
LINE 1: SELECT '"\u0000"'::jsonb;
73
DETAIL: \u0000 cannot be converted to text.
74
CONTEXT: JSON data, line 1: ...
69
75
-- use octet_length here so we don't get an odd unicode char in the
71
77
SELECT octet_length('"\uaBcD"'::jsonb::text); -- OK, uppercase and lower case both OK
716
SELECT '[1,2]'::jsonb @> '[1,2,2]'::jsonb;
722
SELECT '[1,1,2]'::jsonb @> '[1,2,2]'::jsonb;
728
SELECT '[[1,2]]'::jsonb @> '[[1,2,2]]'::jsonb;
734
SELECT '[1,2,2]'::jsonb <@ '[1,2]'::jsonb;
740
SELECT '[1,2,2]'::jsonb <@ '[1,1,2]'::jsonb;
746
SELECT '[[1,2,2]]'::jsonb <@ '[[1,2]]'::jsonb;
710
752
SELECT jsonb_contained('{"a":"b"}', '{"a":"b", "b":1, "c":null}');
712
754
-----------------
1762
1804
DETAIL: Unicode low surrogate must follow a high surrogate.
1763
1805
CONTEXT: JSON data, line 1: { "a":...
1764
1806
-- handling of simple unicode escapes
1765
SELECT jsonb '{ "a": "the Copyright \u00a9 sign" }' ->> 'a' AS correct_in_utf8;
1807
SELECT jsonb '{ "a": "the Copyright \u00a9 sign" }' as correct_in_utf8;
1809
-------------------------------
1810
{"a": "the Copyright © sign"}
1813
SELECT jsonb '{ "a": "dollar \u0024 character" }' as correct_everywhere;
1815
-----------------------------
1816
{"a": "dollar $ character"}
1819
SELECT jsonb '{ "a": "dollar \\u0024 character" }' as not_an_escape;
1821
-----------------------------------
1822
{"a": "dollar \\u0024 character"}
1825
SELECT jsonb '{ "a": "null \u0000 escape" }' as fails;
1826
ERROR: unsupported Unicode escape sequence
1827
LINE 1: SELECT jsonb '{ "a": "null \u0000 escape" }' as fails;
1829
DETAIL: \u0000 cannot be converted to text.
1830
CONTEXT: JSON data, line 1: { "a":...
1831
SELECT jsonb '{ "a": "null \\u0000 escape" }' as not_an_escape;
1833
------------------------------
1834
{"a": "null \\u0000 escape"}
1837
SELECT jsonb '{ "a": "the Copyright \u00a9 sign" }' ->> 'a' as correct_in_utf8;
1766
1838
correct_in_utf8
1767
1839
----------------------
1768
1840
the Copyright © sign
1771
SELECT jsonb '{ "a": "dollar \u0024 character" }' ->> 'a' AS correct_everyWHERE;
1843
SELECT jsonb '{ "a": "dollar \u0024 character" }' ->> 'a' as correct_everywhere;
1772
1844
correct_everywhere
1773
1845
--------------------
1774
1846
dollar $ character
1777
SELECT jsonb '{ "a": "null \u0000 escape" }' ->> 'a' AS not_unescaped;
1849
SELECT jsonb '{ "a": "dollar \\u0024 character" }' ->> 'a' as not_an_escape;
1851
-------------------------
1852
dollar \u0024 character
1855
SELECT jsonb '{ "a": "null \u0000 escape" }' ->> 'a' as fails;
1856
ERROR: unsupported Unicode escape sequence
1857
LINE 1: SELECT jsonb '{ "a": "null \u0000 escape" }' ->> 'a' as fai...
1859
DETAIL: \u0000 cannot be converted to text.
1860
CONTEXT: JSON data, line 1: { "a":...
1861
SELECT jsonb '{ "a": "null \\u0000 escape" }' ->> 'a' as not_an_escape;
1779
1863
--------------------
1780
1864
null \u0000 escape