Home > Back-end >  trino or presto cast '["b", "a", "b", "c"]' into a
trino or presto cast '["b", "a", "b", "c"]' into a

Time:06-23

is there a good way to cast a json type of array '["b", "a", "b", "c"]' into an array.

e.g. something that looks like this

select array['b', 'a', 'c', 'b'];

CodePudding user response:

I guess we can do something like this in Javascript:

const jsonArray = '["b", "a", "b", "c"]';

const myArr = JSON.parse(jsonArray);

CodePudding user response:

I found it in the documentation:

select CAST(JSON '["b", "a", "b", "c"]' AS ARRAY(varchar));
  • Related