json_get_alloc_string_vec_by_path Subroutine

private subroutine json_get_alloc_string_vec_by_path(json, me, path, vec, ilen, found)

Alternate version of json_get_alloc_string_vec where input is the path.

This is an alternate version of json_get_string_vec_by_path. This one returns an allocatable length character (where the string length is the maximum length of any element in the array). It also returns an integer array of the actual sizes of the strings in the JSON structure.

Arguments

Type IntentOptional AttributesName
class(json_core), intent(inout) :: json
type(json_value), intent(in), pointer:: me
character(kind=CK,len=*), intent(in) :: path
character(kind=CK,len=:), intent(out), dimension(:), allocatable:: vec
integer(kind=IK), intent(out), dimension(:), allocatable:: ilen

the actual length of each character string in the array

logical(kind=LK), intent(out), optional :: found

Contents


Source Code

    subroutine json_get_alloc_string_vec_by_path(json, me, path, vec, ilen, found)

    implicit none

    class(json_core),intent(inout)      :: json
    type(json_value),pointer,intent(in) :: me
    character(kind=CK,len=*),intent(in) :: path
    character(kind=CK,len=:),dimension(:),allocatable,intent(out) :: vec
    integer(IK),dimension(:),allocatable,intent(out) :: ilen !! the actual length
                                                             !! of each character
                                                             !! string in the array
    logical(LK),intent(out),optional :: found

    type(json_value),pointer :: p

    call json%get(me, path, p, found)

    if (present(found)) then
        if (.not. found) return
    else
        if (json%exception_thrown) return
    end if

    call json%get(p, vec, ilen)

    if (present(found) .and. json%exception_thrown) then
        call json%clear_exceptions()
        found = .false.
    end if

    end subroutine json_get_alloc_string_vec_by_path