private subroutine json_get_array(me, array_callback)
Arguments
Description
This routine calls the user-supplied array_callback_func subroutine
for each element in the array.
Note
For integer, double, logical, and character arrays,
higher-level routines are provided (see
json_get), so
this routine does not have to be used for those cases.
Variables
Type | Visibility |
Attributes | | Name | | Initial | |
type(json_value), |
public, |
pointer | :: |
element | | | |
integer(kind=IK), |
public |
| :: |
i | | | |
integer(kind=IK), |
public |
| :: |
count | | | |
Source Code
subroutine json_get_array(me, array_callback)
implicit none
type(json_value),pointer,intent(in) :: me
procedure(array_callback_func) :: array_callback
type(json_value),pointer :: element
integer(IK) :: i, count
if ( exception_thrown ) return
nullify(element)
select case (me%var_type)
case (json_array)
count = json_count(me)
element => me%children
do i = 1, count ! callback for each child
call array_callback(element, i, count)
element => element%next
end do
case default
call throw_exception('Error in json_get_array:'//&
' Resolved value is not an array ')
end select
!cleanup:
if (associated(element)) nullify(element)
end subroutine json_get_array