Image

4

Finding and Getting Data

Simply having data in a MySQL JSON data type column is not much good by itself. Thankfully the engineers at MySQL have provided many extremely useful functions to get into the data, and this chapter delves into the functions for finding and retrieving that data.

All Keys

In Chapter 3, the JSON_KEYS() function was introduced. This function returns the top level of a JSON object as an array. Without the optional path, the function provides the top-level keys. With the optional path, it provides the top-level keys from that particular path.

Format: JSON_KEYS(json_doc[, path])

Example 4-1 JSON_KEYS with top level of JSON ...

Get MySQL and JSON: A Practical Programming Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.