SQL Language (MOSC)

MOSC Banner

How to extract specific array item with json_value

edited Apr 1, 2020 9:40AM in SQL Language (MOSC) 3 commentsAnswered ✓

Hi,

I have a json data as below and I can use the below SQL to extract the Subject value

SELECT JSON_VALUE('{"payload": {

  "partId": "",

  "mimeType": "text/html",

  "filename": "",

  "headers": [

   {

    "name": "Delivered-To",

    "value": "sndata@abc.com"

   },

   {

    "name": "Subject",

    "value": "Testing subject"

   }]}}', '$.payload.headers[1].value' ERROR ON ERROR) AS value

  FROM DUAL;

provided the JSON has fix content sequence in the headers section.

If the headers array items sequence is not fixed, how should I get the value for the array item with name="Subject" ?

Thanks

Pek

Howdy, Stranger!

Log In

To view full details, sign in to My Oracle Support Community.

Register

Don't have a My Oracle Support Community account? Click here to get started.

Category Leaderboard

Top contributors this month

New to My Oracle Support Community? Visit our Welcome Center

MOSC Help Center