subroutine get_real(this, path, value)
use fson_value_m, only: type_integer, type_real, type_logical, fson_value
implicit none
type(fson_value), pointer :: this, p
character(len=*), optional :: path
real :: 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
else if (p % value_type == TYPE_REAL) then
value = p % value_real
else if (p % value_type == TYPE_LOGICAL) then
if (p % value_logical) then
value = 1
else
value = 0
end if
else
print *, "Unable to resolve value to real: ", path
call exit(1)
end if
end subroutine get_real