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?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.