Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PostgreSQL JSONB (Selecting value returns value with quotes, "value")

Have a JSONB column with data like this:

{"title": "Some book!", "uniqueId": "11264299-2543-566"}

When I try to select the values, they are returned with double quotes surrounding them...

SELECT 'Some book!', json_data->'title' FROM myJsonTable

Returns:

Some book!      "Some book!"
like image 820
Brad Avatar asked Mar 16 '23 17:03

Brad


1 Answers

Instead of using json_data->'title', I needed to use jsonb_extract_path_text(json_data, 'title')...

Edit: Or as Lucas said in the comment, use json_data->>'title'...

like image 188
Brad Avatar answered Mar 19 '23 05:03

Brad