json_get_by_path Subroutine

private subroutine json_get_by_path(json, me, path, p, found)

Returns the json_value pointer given the path string.

It uses either of two methods:

  • The original JSON-Fortran defaults
  • RFC 6901

Arguments

Type IntentOptional AttributesName
class(json_core), intent(inout) :: json
type(json_value), intent(in), pointer:: me

a JSON linked list

character(kind=CK,len=*), intent(in) :: path

path to the variable

type(json_value), intent(out), pointer:: p

pointer to the variable specified by path

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

true if it was found


Calls

proc~~json_get_by_path~~CallsGraph proc~json_get_by_path json_get_by_path proc~integer_to_string integer_to_string proc~json_get_by_path->proc~integer_to_string

Contents

Source Code


Source Code

    subroutine json_get_by_path(json, me, path, p, found)

    implicit none

    class(json_core),intent(inout)       :: json
    type(json_value),pointer,intent(in)  :: me     !! a JSON linked list
    character(kind=CK,len=*),intent(in)  :: path   !! path to the variable
    type(json_value),pointer,intent(out) :: p      !! pointer to the variable
                                                   !! specified by `path`
    logical(LK),intent(out),optional     :: found  !! true if it was found

    character(kind=CK,len=max_integer_str_len),allocatable :: path_mode_str !! string version
                                                                            !! of `json%path_mode`

    nullify(p)

    if (.not. json%exception_thrown) then

        ! note: it can only be 1 or 2 (3 not currently enabled)
        select case (json%path_mode)
        case(1_IK)
            call json%json_get_by_path_default(me, path, p, found)
        case(2_IK)
            call json%json_get_by_path_rfc6901(me, path, p, found)
        case(3_IK)
            call json%json_get_by_path_jsonpath_bracket(me, path, p, found)
        case default
            call integer_to_string(json%path_mode,int_fmt,path_mode_str)
            call json%throw_exception('Error in json_get_by_path: Unsupported path_mode: '//&
                                        trim(path_mode_str))
            if (present(found)) found = .false.
        end select

        if (present(found)) then
            if (.not. found) call json%clear_exceptions()
        end if

    else
        if (present(found)) found = .false.
    end if

    end subroutine json_get_by_path