Closed nyckmaia closed 5 years ago
I would like to update / replace the old JSON file values by new ones:
I have a simple JSON file like this:
{ "height": 1, "weight": 2, "size": 3 }
I tried to use the json%update function but this function do not overwrite the new values on the actual JSON file.
json%update
subroutine fortran_subroutine() bind(C) use, intrinsic :: ISO_C_BINDING use json_module implicit none type(json_file) :: json logical :: found integer :: height, weight, size ! initialize the class call json%initialize() ! read the file call json%load_file(filename = 'my_json.json') call json%update('height', 100, found) call json%update('weight', 200, found) call json%update('size', 300, found) ! clean up call json%destroy() if (json%failed()) stop 1 end subroutine fortran_subroutine
After the execution of this subroutine, I would like that my_json should be like:
my_json
{ "height": 100, "weight": 200, "size": 300 }
How can I update the values direct on my JSON file?
Ok...I found...
call json%print_file("my_json.json")
I would like to update / replace the old JSON file values by new ones:
I have a simple JSON file like this:
I tried to use the
json%update
function but this function do not overwrite the new values on the actual JSON file.After the execution of this subroutine, I would like that
my_json
should be like:How can I update the values direct on my JSON file?