| От | Tom Lane |
|---|---|
| Тема | Re: [GENERAL] Removing null bytes from a json column |
| Дата | |
| Msg-id | 28018.1497193323@sss.pgh.pa.us обсуждение |
| Ответ на | [GENERAL] Removing null bytes from a json column (Timothy Garnett <tgarnett@panjiva.com>) |
| Список | pgsql-general |
Timothy Garnett <tgarnett@panjiva.com> writes:
> Does anyone have some tips on how to deal with an existing json type column
> that has some null bytes ( \u0000) in it? It seems like anything I do that
> touches any row with a null byte just errors. I'd love to just remove them
> if I could find some way to find them, but I'm having trouble even figuring
> out how to do that.
Doesn't it work to cast to text and do a LIKE or regex search?
regression=# select '{"z":"\u0000"}'::json::text ~ '\\u0000';
?column?
----------
t
(1 row)
regression=# select '{"z":"\u0001"}'::json::text ~ '\\u0000';
?column?
----------
f
(1 row)
It's true that we won't let you cast such a value to JSONB or do any
exciting JSON-ish manipulations on it, but I'm not seeing an error
in cast-to-text.
regards, tom lane
В списке pgsql-general по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера