subroutine get_chars(this, path, value)
use fson_value_m, only: type_string, fson_value
use fson_string_m, only: fson_string_copy
implicit none
type(fson_value), pointer :: this, p
character(len=*), optional :: path
character(len=*) :: 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_STRING) then
call fson_string_copy(p % value_string, value)
else
print *, "Unable to resolve value to characters: ", path
call exit(1)
end if
end subroutine get_chars