-3

I have json of following format and now I want to parse this json and store the result into relational table with assigning column names to these column less entities under row array.

{
  "rowset": [
    {
      "row": [
        1,
        34,
        "mani"
      ]
    },
    {
      "row": [
        156,
        4,
        "nani"
      ]
    }
  ]
}
nisha
  • 1
  • 2
  • 2
    https://docs.oracle.com/cd/E59726_01/doc.50/e39149/apex_json.htm#AEAPI29635 – Rene Aug 07 '18 at 10:44
  • 1
    Please take some time to read the help page, https://stackoverflow.com/help/how-to-ask – v8-E Aug 07 '18 at 10:53
  • Possible duplicate of [Parsing values from a JSON file?](https://stackoverflow.com/questions/2835559/parsing-values-from-a-json-file) – iamdanchiv Aug 07 '18 at 11:00

1 Answers1

0

Here is a first idea on how to start. But remember that there are tons of tutorials on this and stackoverflow is there to help you solving a problem and not to do it alone for you.

 DECLARE
        l_source VARCHAR2(200);
        l_blob blob := :body;
        l_clob clob;
        l_values apex_json.t_values;
        l_data_count integer;   
        l_var ...
        --LOOP VARS
        l_var2 ...

    BEGIN
        l_clob := wwv_flow_utilities.blob_to_clob(l_blob);
        apex_json.parse(
            p_values => l_values,
            p_source => l_clob
        );  
        l_data_count := apex_json.get_count (   
                            p_values => l_values,   
                            p_path  => 'nestedJSON' );   
        l_var := apex_json.get_varchar2 (   
                                    p_values => l_values,   
                                    p_path  => 'var');


       FOR i IN 1 .. l_data_count LOOP

          l_var2 := apex_json.get_varchar2(   
                    p_values => l_values,   
                    p_path  => 'nestedJSON[%d].var2',   
                    p0      => i);


           INSERT INTO table
               (var, var2)
           VALUES
               (l_var, l_var2);
       END LOOP;
    END;
TeAyudo
  • 59
  • 6