json_count Function

private function json_count(json, p) result(count)

Count the number of children in the object or array.

History

  • JW : 1/4/2014 : Original routine removed. Now using n_children variable. Renamed from json_value_count.

Type Bound

json_core

Arguments

Type IntentOptional Attributes Name
class(json_core), intent(inout) :: json
type(json_value), intent(in), pointer :: p

this should normally be a json_object or a json_array. For any other variable type this will return 0.

Return Value integer(kind=IK)

number of children in p.


Calls

proc~~json_count~~CallsGraph proc~json_count json_value_module::json_core%json_count none~throw_exception json_value_module::json_core%throw_exception proc~json_count->none~throw_exception proc~json_throw_exception json_value_module::json_core%json_throw_exception none~throw_exception->proc~json_throw_exception

Source Code

    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