json_print_to_filename Subroutine

private subroutine json_print_to_filename(json, p, filename)

Print the json_value structure to a file.

Type Bound

json_core

Arguments

Type IntentOptional Attributes Name
class(json_core), intent(inout) :: json
type(json_value), intent(in), pointer :: p
character(kind=CDK, len=*), intent(in) :: filename

the filename to print to (should not already be open)


Calls

proc~~json_print_to_filename~~CallsGraph proc~json_print_to_filename json_value_module::json_core%json_print_to_filename none~throw_exception json_value_module::json_core%throw_exception proc~json_print_to_filename->none~throw_exception proc~json_throw_exception json_value_module::json_core%json_throw_exception none~throw_exception->proc~json_throw_exception

Source Code

    subroutine json_print_to_filename(json,p,filename)

    implicit none

    class(json_core),intent(inout)       :: json
    type(json_value),pointer,intent(in)  :: p
    character(kind=CDK,len=*),intent(in) :: filename  !! the filename to print to
                                                      !! (should not already be open)

    integer(IK) :: iunit  !! file unit for `open` statement
    integer(IK) :: istat  !! `iostat` code for `open` statement

    open(newunit=iunit,file=filename,status='REPLACE',iostat=istat FILE_ENCODING )
    if (istat==0) then
        call json%print(p,iunit)
        close(iunit,iostat=istat)
    else
        call json%throw_exception('Error in json_print_to_filename: could not open file: '//&
                              trim(filename))
    end if

    end subroutine json_print_to_filename