Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | intent(in), | pointer | :: | me | object or array JSON data |
|
integer(kind=IK), | intent(in) | :: | idx | index of the child |
||
type(json_value), | intent(inout), | pointer | :: | p | pointer to the child |
Returns a child in the object or array given the index.
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
integer(kind=IK), | public | :: | i |
subroutine json_value_get_by_index(me, idx, p)
implicit none
type(json_value),pointer,intent(in) :: me !! object or array JSON data
integer(IK),intent(in) :: idx !! index of the child
type(json_value),pointer :: p !! pointer to the child
integer(IK) :: i
nullify(p)
if (.not. exception_thrown) then
if (associated(me%children)) then
p => me%children
do i = 1, idx - 1
if (associated(p%next)) then
p => p%next
else
call throw_exception('Error in json_value_get_by_index:'//&
' p%next is not associated.')
nullify(p)
return
end if
end do
else
call throw_exception('Error in json_value_get_by_index:'//&
' me%children is not associated.')
end if
end if
end subroutine json_value_get_by_index