Skip to content

Instantly share code, notes, and snippets.

@runa
Created September 29, 2015 11:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save runa/c27f2fb28b371baaff2b to your computer and use it in GitHub Desktop.
Save runa/c27f2fb28b371baaff2b to your computer and use it in GitHub Desktop.
mysql> select json_extract('{"phones":["555-5555"],"emails":["info@x.com.ar"]}',"$.emails[0]");
+----------------------------------------------------------------------------------+
| json_extract('{"phones":["555-5555"],"emails":["info@x.com.ar"]}',"$.emails[0]") |
+----------------------------------------------------------------------------------+
| NULL |
+----------------------------------------------------------------------------------+
@runa
Copy link
Author

runa commented Sep 29, 2015

mysql> select json_extract('{"f":["foo"],"b":["bar"]}',"$.b[0]");
+----------------------------------------------------+
| json_extract('{"f":["foo"],"b":["bar"]}',"$.b[0]") |
+----------------------------------------------------+
| NULL                                               |
+----------------------------------------------------+

@svetasmirnova
Copy link

This is a bug. Funny, but select json_extract('{"f":["foo"],"b":["bar", "baz"]}',"$.b[1]"); works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment