1

I have the following JSON object -

{
  "items": [
    {
      "tableName": "contacts",
      "count": 1,
      "columnNames": [
        "id"
      ],
      "rows": [
        [
          "45"
        ]
      ]
    }
  ],
  "links": [
    {
      "rel": "self",

    },
    {
      "rel": "describedby",

    }
  ]
}

I am trying to extract the value from rows- I need the value 45.

I tried to extract using -

row_id := apex_json.get_number ('rows[%d]', 1);

How I can extract it? Thanks in advance.

1 Answer 1

1

Here's an example:

declare

  l_json_val apex_json.t_values;
  l_clob     clob;
  l_row_val  varchar2(255);

begin

  l_clob := q'-
    {
      "items": [
        {
          "tableName": "contacts",
          "count": 1,
          "columnNames": [
            "id"
          ],
          "rows": [
            [
              "45"
            ]
          ]
        }
      ],
      "links": [
        {
          "rel": "self",

        },
        {
          "rel": "describedby",

        }
      ]
    }
  -';

  apex_json.parse(p_values => l_json_val, p_source => l_clob, p_strict => false); 

  l_row_val := apex_json.get_varchar2(p_path => 'items[1].rows[1][1]', p_values => l_json_val);

  dbms_output.put_line(l_row_val);

end;

Note that the path expressions with apex_json use a 1 base array index, not 0.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.