Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | intent(in), | pointer | :: | me | ||
character(kind=CK,len=:), | intent(out), | allocatable | :: | value |
Get a character string from a json_value.
subroutine json_get_string(me, value)
implicit none
type(json_value),pointer,intent(in) :: me
character(kind=CK,len=:),allocatable,intent(out) :: value
value = ''
if (.not. exception_thrown) then
select case (me%var_type)
case (json_string)
if (allocated(me%str_value)) then
call unescape_string(me%str_value, value)
else
call throw_exception('Error in json_get_string:'//&
' me%str_value not allocated')
end if
case default
call throw_exception('Error in json_get_string:'//&
' Unable to resolve value to characters: '//me%name)
! Note: for the other cases, we could do val to string conversions.
end select
end if
end subroutine json_get_string