private subroutine json_get_string_with_path(me, path, value, found)
Arguments
Type |
Intent | Optional |
Attributes | | Name | |
type(json_value), |
intent(in), |
|
pointer | :: |
me | |
character(kind=CK,len=*), |
intent(in) |
|
| :: |
path | |
character(kind=CK,len=:), |
intent(out), |
|
allocatable | :: |
value | |
logical(kind=LK), |
intent(out), |
optional |
| :: |
found | |
Description
Get a character string from a json_value, given the path.
Variables
Type | Visibility |
Attributes | | Name | | Initial | |
type(json_value), |
public, |
pointer | :: |
p | | | |
Source Code
subroutine json_get_string_with_path(me, path, value, found)
implicit none
type(json_value),pointer,intent(in) :: me
character(kind=CK,len=*),intent(in) :: path
character(kind=CK,len=:),allocatable,intent(out) :: value
logical(LK),intent(out),optional :: found
type(json_value),pointer :: p
value = ''
if ( exception_thrown ) then
if ( present(found) ) found = .false.
return
end if
nullify(p)
call json_get_by_path(me=me, path=path, p=p)
if (.not. associated(p)) then
call throw_exception('Error in json_get_string:'//&
' Unable to resolve path: '//trim(path))
else
call json_get_string(p,value)
nullify(p)
end if
if (allocated(value) .and. .not. exception_thrown) then
if (present(found)) found = .true.
else
if (present(found)) then
found = .false.
call json_clear_exceptions()
end if
end if
!cleanup:
if (associated(p)) nullify(p)
end subroutine json_get_string_with_path