Get a logical value from a json_value.
If strict_type_checking
is False, then the following assumptions are made:
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(json_core), | intent(inout) | :: | json | |||
type(json_value), | intent(in), | pointer | :: | me | ||
logical(kind=LK), | intent(out) | :: | value |
subroutine json_get_logical(json, me, value) implicit none class(json_core),intent(inout) :: json type(json_value),pointer,intent(in) :: me logical(LK),intent(out) :: value value = .false. if ( json%exception_thrown ) return if (me%var_type == json_logical) then value = me%log_value else if (json%strict_type_checking) then if (allocated(me%name)) then call json%throw_exception('Error in json_get_logical: '//& 'Unable to resolve value to logical: '//& me%name) else call json%throw_exception('Error in json_get_logical: '//& 'Unable to resolve value to logical') end if else !type conversions select case (me%var_type) case (json_integer) value = (me%int_value > 0_IK) case (json_real) value = (me%dbl_value > 0.0_RK) case (json_string) value = (me%str_value == true_str) case default if (allocated(me%name)) then call json%throw_exception('Error in json_get_logical: '//& 'Unable to resolve value to logical: '//& me%name) else call json%throw_exception('Error in json_get_logical: '//& 'Unable to resolve value to logical') end if end select end if end if end subroutine json_get_logical