Count the number of children in the object or array.
n_children
variable.
Renamed from json_value_count
.Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(json_core), | intent(inout) | :: | json | |||
type(json_value), | intent(in), | pointer | :: | p | this should normally be a |
number of children in p
.
function json_count(json,p) result(count)
implicit none
class(json_core),intent(inout) :: json
type(json_value),pointer,intent(in) :: p !! this should normally be a `json_object`
!! or a `json_array`. For any other
!! variable type this will return 0.
integer(IK) :: count !! number of children in `p`.
if (associated(p)) then
count = p%n_children
else
call json%throw_exception('Error in json_count: '//&
'pointer is not associated.')
end if
end function json_count