json_file_destroy Subroutine

private subroutine json_file_destroy(me, destroy_core)

Destroy the json_value data in a json_file. This must be done when the variable is no longer needed, or will be reused to open a different file. Otherwise a memory leak will occur.

Optionally, also destroy the json_core instance (this is not necessary to prevent memory leaks, since a json_core does not use pointers).


  • 12/9/2013 : Created
  • 4/26/2016 : Added optional destroy_core argument


Type IntentOptional AttributesName
class(json_file), intent(inout) :: me
logical, intent(in), optional :: destroy_core

to also destroy the json_core. default is to leave it as is.


Source Code

Source Code

    subroutine json_file_destroy(me,destroy_core)

    implicit none

    class(json_file),intent(inout) :: me
    logical,intent(in),optional :: destroy_core  !! to also destroy the [[json_core(type)]].
                                                 !! default is to leave it as is.

    if (associated(me%p)) call me%core%destroy(me%p)

    if (present(destroy_core)) then
        if (destroy_core) call me%core%destroy()
    end if

    end subroutine json_file_destroy