MySQL Forums
Forum List  »  General

Re: How to convert a JSON string containing map data to a TABLE.
Posted by: Steven Hughes
Date: May 15, 2022 04:04PM

Syntax of JSON_TABLE function is:

JSON_TABLE(json_string, '$.<path>' COLUMNS (
column_name_1 <type> PATH '$.<path>',
column_name_2 <type> PATH '$.<path>')
) result;

To what do I set the paths? MySQL seems to object to numeric paths, e.g. $.1, which I can't use as the number will change.

In SQL Server, there is a lovely OPENJSON function which gives me exactly what I need, viz.

SELECT *
FROM OPENJSON(@json_string);

which produces a table of: key, value and type, over which I can retrieve my values.

What is the equivalent mySQL function?

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.