S
S
Steve2021-06-16 10:59:12
PostgreSQL
Steve, 2021-06-16 10:59:12

Converting table text entries to json?

There are hundreds of records in the table in the form of "{\"tags_in\":[393],\"tags_out\":[395]}"a string.

Is it possible to convert them to json {"tags_in":[393],"tags_out":[395]}without losing this data?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Melkij, 2021-06-16
@CenterJoin

update tablename set jsoncol = cast(cast(data as json)#>>'{}' as json);

A
Alexey Shashenkov, 2021-06-16
@teknik2008

select '{"tags_in":[393],"tags_out":[395]}'::jsonb

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question