I'm getting the hang of SQL but am struggling with JSON data handling. I just can't get it to work. I'm getting the subject error when trying to run a very basic query, so I'm missing something fundamental.
I've read through many tutorials and this post but I think I need an example using the data I'm working with.
Error
Error Code: 3143. Invalid JSON path expression. The error is around character position 3.
Example JSON Data
{"1": {"name": "Part Source", "type": "Drop-Down List", "value": "Manufactured"}, "28": {"name": "Status", "type": "Drop-Down List", "value": "Current"}}
{"1": {"name": "Part Source", "type": "Drop-Down List", "value": "Manufactured"}, "28": {"name": "Status", "type": "Drop-Down List", "value": "Current"}}
{"1": {"name": "Part Source", "type": "Drop-Down List", "value": "Manufactured"}, "28": {"name": "Status", "type": "Drop-Down List", "value": "Current"}}
The data resides in a table named part
in a column named customFields
.
I've tried many things but to start simple, below is my attempt to extract the name from the first nested key pair. This yields the above error.
SELECT customFields->>'$.1.name'
FROM part;
I also tried with this the positional [0] and [1] after $.1.name
with the same result.