The following statement returns a value of 10:
SELECT JSON_VALUE('{"item1":10}', '$.item1') AS "value" FROM DUMMY;
The following statement returns a value of 5:
SELECT JSON_VALUE('{"item1":{"sub1":10}, "item2":{"sub2":5}, "item3":{"sub3":7}}', '$.*.sub2') AS "value" FROM DUMMY;
The following statement returns a value of 0:
SELECT JSON_VALUE('[0, 1, 2, 3]', '$[0]') AS "value" FROM DUMMY;
The following statement returns the value "No last name found":
SELECT JSON_VALUE('{"firstname":"John"}', '$.lastname' DEFAULT 'No last name found' ON EMPTY) AS "Last Name" FROM DUMMY;
The following statement causes a type conversion error to demonstrate the behavior for ERROR ON ERROR:
SELECT JSON_VALUE('{"item":"string"}', '$.item' RETURNING DECIMAL ERROR ON ERROR) AS "Item" FROM DUMMY;
The following statement demonstrates what happens when there is no value (the object does not have the name "last name"):
SELECT JSON_VALUE('{"firstname":"John"}', 'strict $.lastname' ERROR ON ERROR) AS "Last Name" FROM DUMMY;