An error checking routine to call after a file (or string) has been parsed. It will throw an exception if there are any other non-whitespace characters in the file.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(json_core), | intent(inout) | :: | json | |||
integer(kind=IK), | intent(in) | :: | unit | file unit number |
||
character(kind=CK,len=*), | intent(in) | :: | str | string containing JSON
data (only used if |
subroutine json_parse_end(json, unit, str)
implicit none
class(json_core),intent(inout) :: json
integer(IK),intent(in) :: unit !! file unit number
character(kind=CK,len=*),intent(in) :: str !! string containing JSON
!! data (only used if `unit=0`)
logical(LK) :: eof !! end-of-file flag
character(kind=CK,len=1) :: c !! character read from file
!! (or string) by [[pop_char]]
! first check for exceptions:
if (json%exception_thrown) return
! pop the next non whitespace character off the file
call json%pop_char(unit, str=str, eof=eof, skip_ws=.true., &
skip_comments=json%allow_comments, popped=c)
if (.not. eof) then
call json%throw_exception('Error in json_parse_end:'//&
' Unexpected character found after parsing value. "'//&
c//'"')
end if
end subroutine json_parse_end