Get an integer value from a json_value, given the path string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(json_core), | intent(inout) | :: | json | |||
type(json_value), | intent(in), | pointer | :: | me | ||
character(kind=CK,len=*), | intent(in) | :: | path | |||
integer(kind=IK), | intent(out) | :: | value | |||
logical(kind=LK), | intent(out), | optional | :: | found |
subroutine json_get_integer_by_path(json, me, path, value, found)
implicit none
class(json_core),intent(inout) :: json
type(json_value),pointer,intent(in) :: me
character(kind=CK,len=*),intent(in) :: path
integer(IK),intent(out) :: value
logical(LK),intent(out),optional :: found
type(json_value),pointer :: p
value = 0
if ( json%exception_thrown ) then
if ( present(found) ) found = .false.
return
end if
nullify(p)
call json%get(me=me, path=path, p=p)
if (.not. associated(p)) then
call json%throw_exception('Error in json_get_integer_by_path:'//&
' Unable to resolve path: '// trim(path))
else
call json%get(p,value)
nullify(p)
end if
if ( json%exception_thrown ) then
if ( present(found) ) then
found = .false.
call json%clear_exceptions()
end if
else
if ( present(found) ) found = .true.
end if
end subroutine json_get_integer_by_path