Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | intent(inout) | :: | me | |||
integer(kind=IK), | intent(in), | optional | :: | val | if the value is also to be set (if not present, then 0 is used). |
|
character(kind=CK,len=*), | intent(in), | optional | :: | name | if the name is also to be changed. |
Change the json_value variable to an integer.
subroutine to_integer(me,val,name)
implicit none
type(json_value),intent(inout) :: me
integer(IK),intent(in),optional :: val !! if the value is also to be set (if not present, then 0 is used).
character(kind=CK,len=*),intent(in),optional :: name !! if the name is also to be changed.
!set type and value:
call destroy_json_data(me)
me%var_type = json_integer
allocate(me%int_value)
if (present(val)) then
me%int_value = val
else
me%int_value = 0 !default value
end if
!name:
if (present(name)) me%name = trim(name)
end subroutine to_integer