subroutine get_logical(this, path, value)
use fson_value_m, only: type_integer, type_logical, fson_value
implicit none
type(fson_value), pointer :: this, p
character(len=*), optional :: path
logical :: value
nullify(p)
if (present(path)) then
call get_by_path(this=this, path=path, p=p)
else
p => this
end if
if (.not.associated(p)) then
print *, "Unable to resolve path: ", path
call exit(1)
end if
if (p % value_type == TYPE_INTEGER) then
value = (p % value_integer > 0)
else if (p % value_type == TYPE_LOGICAL) then
value = p % value_logical
else
print *, "Unable to resolve value to logical: ", path
call exit(1)
end if
end subroutine get_logical