Change the json_value variable to an integer.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(json_core), | intent(inout) | :: | json | |||
type(json_value), | pointer | :: | p | |||
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. |
subroutine to_integer(json,p,val,name)
implicit none
class(json_core),intent(inout) :: json
type(json_value),pointer :: p
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(p)
p%var_type = json_integer
allocate(p%int_value)
if (present(val)) then
p%int_value = val
else
p%int_value = 0_IK !default value
end if
!name:
if (present(name)) call json%rename(p,name)
end subroutine to_integer