Changing a JSON object parsed with APEX_JSON

by Geison Santos   Last Updated August 10, 2018 13:06 PM

I would like to be able to change a JSON object parsed with the APEX_JSON.parse() function, but I found nothing in the official documentation, no tips or examples about that.

In the code below I putted comments in the specific points in order to give a clear idea about my need.


    j apex_json.t_values;
    l_paths apex_t_varchar2;    
    writers clob;
    json_object_result clob;

    writers := '[
            "id": null,
            "hashCode": "7ef605fc8dba5425d6965fbd4c8fbe1f",
            "description": "Machado de Assis",
            "base64Img": "8eNZ28Dh5rZQIPhNEfwqoo1LCVx..."
            "id": 151,
            "hashCode": "a8f15eda80c50adb0e71943adc8015cf",
            "description": "José Alencar",
            "base64Img": "/XIQIHCol8eNZ28Dh5rZQIPhNEfwqoo1LCVx/9k=..."

    apex_json.parse(j, writers);

    l_paths := apex_json.find_paths_like (
        p_values         => j,
        p_return_path => '[%]',
        p_subpath       => '.hashCode',
        p_value    => '7ef605fc8dba5425d6965fbd4c8fbe1f'

    dbms_output.put_line('Itens found: ' || l_paths.count);

    if (l_paths.count = 1) then 
        dbms_output.put_line('id: ' || apex_json.get_varchar2(p_values => j, p_path => l_paths(1) || '.id'));
        dbms_output.put_line('hashCode: ' || apex_json.get_varchar2(p_values => j, p_path => l_paths(1) || '.hashCode'));
        dbms_output.put_line('description: ' || apex_json.get_varchar2(p_values => j, p_path => l_paths(1) || '.description'));
        dbms_output.put_line('base64Img: ' || apex_json.get_varchar2(p_values => j, p_path => l_paths(1) || '.base64Img'));
--      Here I would like to nullify base64Img attribute value
        json_object_result := 'here goes the object matched in the search with the base64Img attribute value null';
    end if;


In my json_object_result variable I would like to save the JSON object matched in the apex_json.find_paths_like() with its base64Img attribute null. In my example the result would be

{ "id": null, "hashCode": "7ef605fc8dba5425d6965fbd4c8fbe1f", "description": "Machado de Assis", "base64Img": "" }


{ "id": null, "hashCode": "7ef605fc8dba5425d6965fbd4c8fbe1f", "description": "Machado de Assis" }

Is it possible to make something like that with APEX_JSON?

Related Questions

PL/SQL code review guidelines/checklist

Updated March 01, 2016 03:02 AM

whatsapp api used un oracle apex

Updated October 29, 2018 07:06 AM

Oracle Apex IR subscription not working

Updated August 24, 2018 22:06 PM

Connect MariaDB and Oracle XE

Updated July 24, 2016 08:02 AM