0

I am trying to get the value of an array made json in Laravel through unquoting extraction operator but it doesn't work.

Json in database

["a","b","c"]

Eloquent

->select('data->[2] as data')

SQL generated for laravel

"select json_unquote(json_extract(`data`, '$."[2]"')) as `data` from `table`"

when should it be like this:

"select json_unquote(json_extract(`data`, '$[2]')) as `data` from `table`"

How should I create the 'select' in eloquent for when the json is a simple array???

The json is very big, that's why i don't want to use json_decode (php)

joserick
  • 327
  • 3
  • 11

0 Answers0