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
call json%throw_exception('Error in json_get_logical: '//&
'Unable to resolve value to logical: '//&
me%name)
else
!type conversions
select case (me%var_type)
case (json_integer)
value = (me%int_value > 0_IK)
case (json_double)
value = (me%dbl_value > 0.0_RK)
case (json_string)
value = (me%str_value == true_str)
case default
call json%throw_exception('Error in json_get_logical: '//&
'Unable to resolve value to logical: '//&
me%name)
end select
end if
end if
end subroutine json_get_logical