Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | intent(in), | pointer | :: | me | ||
character(kind=CK,len=*), | intent(in) | :: | name | the name of a child of "me" |
||
type(json_value), | intent(inout), | pointer | :: | p | pointer to the child |
Returns a child in the object or array given the name string.
It is a case-sensitive search, and the name string is not trimmed. So, for example,
'a ' /= 'A ' /= 'a '
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
integer(kind=IK), | public | :: | i | ||||
integer(kind=IK), | public | :: | n_children |
subroutine json_value_get_by_name_chars(me, name, p)
implicit none
type(json_value),pointer,intent(in) :: me
character(kind=CK,len=*),intent(in) :: name !! the name of a child of "me"
type(json_value),pointer :: p !! pointer to the child
integer(IK) :: i,n_children
nullify(p)
if (.not. exception_thrown) then
if (associated(me)) then
if (me%var_type==json_object) then
n_children = json_count(me)
p => me%children !start with first one
do i=1, n_children
if (allocated(p%name)) then
if (p%name == name) return
end if
p => p%next
end do
end if
!did not find anything:
call throw_exception('Error in json_value_get_by_name_chars: '//&
'child variable '//trim(name)//' was not found.')
nullify(p)
else
call throw_exception('Error in json_value_get_by_name_chars: '//&
'pointer is not associated.')
end if
end if
end subroutine json_value_get_by_name_chars