json_parse_end Subroutine

private subroutine json_parse_end(json, unit, str)

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 Bound

json_core

Arguments

Type IntentOptional 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 unit=0)


Calls

proc~~json_parse_end~~CallsGraph proc~json_parse_end json_core%json_parse_end none~throw_exception json_core%throw_exception proc~json_parse_end->none~throw_exception proc~pop_char json_core%pop_char proc~json_parse_end->proc~pop_char proc~json_throw_exception json_core%json_throw_exception none~throw_exception->proc~json_throw_exception proc~wrap_json_throw_exception json_core%wrap_json_throw_exception none~throw_exception->proc~wrap_json_throw_exception proc~wrap_json_throw_exception->none~throw_exception interface~to_unicode to_unicode proc~wrap_json_throw_exception->interface~to_unicode proc~to_uni to_uni interface~to_unicode->proc~to_uni proc~to_uni_vec to_uni_vec interface~to_unicode->proc~to_uni_vec

Called by

proc~~json_parse_end~~CalledByGraph proc~json_parse_end json_core%json_parse_end proc~json_parse_file json_core%json_parse_file proc~json_parse_file->proc~json_parse_end proc~json_parse_string json_core%json_parse_string proc~json_parse_string->proc~json_parse_end none~deserialize~2 json_core%deserialize none~deserialize~2->proc~json_parse_string proc~wrap_json_parse_string json_core%wrap_json_parse_string none~deserialize~2->proc~wrap_json_parse_string none~load~2 json_core%load none~load~2->proc~json_parse_file proc~json_file_load json_file%json_file_load proc~json_file_load->none~load~2 proc~json_file_load_from_string json_file%json_file_load_from_string proc~json_file_load_from_string->none~deserialize~2 proc~wrap_json_parse_string->none~deserialize~2 none~deserialize json_file%deserialize none~deserialize->proc~json_file_load_from_string proc~wrap_json_file_load_from_string json_file%wrap_json_file_load_from_string none~deserialize->proc~wrap_json_file_load_from_string proc~assign_string_to_json_file json_file%assign_string_to_json_file proc~assign_string_to_json_file->none~deserialize proc~initialize_json_file_from_string initialize_json_file_from_string proc~initialize_json_file_from_string->none~deserialize proc~initialize_json_file_from_string_v2 initialize_json_file_from_string_v2 proc~initialize_json_file_from_string_v2->none~deserialize proc~wrap_json_file_load_from_string->none~deserialize interface~json_file json_file interface~json_file->proc~initialize_json_file_from_string interface~json_file->proc~initialize_json_file_from_string_v2 proc~wrap_initialize_json_file_from_string wrap_initialize_json_file_from_string interface~json_file->proc~wrap_initialize_json_file_from_string proc~wrap_initialize_json_file_from_string_v2 wrap_initialize_json_file_from_string_v2 interface~json_file->proc~wrap_initialize_json_file_from_string_v2 proc~wrap_assign_string_to_json_file json_file%wrap_assign_string_to_json_file proc~wrap_assign_string_to_json_file->proc~assign_string_to_json_file proc~wrap_initialize_json_file_from_string->proc~initialize_json_file_from_string proc~wrap_initialize_json_file_from_string_v2->proc~initialize_json_file_from_string_v2

Source Code

    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