Returns the json_value pointer given the path string.
It uses either of two methods:
if found
is present, we should clear any exceptions that are thrown
to be consistent with other routines. This is not currently being done.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
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
specify by |
|
logical(kind=LK), | intent(out), | optional | :: | found | true if it was found |
Nodes of different colours represent the following:
Solid arrows point from a procedure to one which it calls. Dashed arrows point from an interface to procedures which implement that interface. This could include the module procedures in a generic interface or the implementation in a submodule of an interface in a parent module. Where possible, edges connecting nodes are given different colours to make them easier to distinguish in large graphs.
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
!! specify 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
else
if (present(found)) found = .false.
end if
end subroutine json_get_by_path