Print the json_value structure to a file.
Type | Intent | Optional | 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) |
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