json_value_add_string_vec Subroutine

private subroutine json_value_add_string_vec(json, p, name, val, trim_str, adjustl_str)

Add a character string vector child to the json_value variable.

Arguments

Type IntentOptional AttributesName
class(json_core), intent(inout) :: json
type(json_value), pointer:: p
character(kind=CK,len=*), intent(in) :: name

variable name

character(kind=CK,len=*), intent(in), dimension(:):: val

array of strings

logical(kind=LK), intent(in), optional :: trim_str

if TRIM() should be called for each element

logical(kind=LK), intent(in), optional :: adjustl_str

if ADJUSTL() should be called for each element


Contents


Source Code

    subroutine json_value_add_string_vec(json, p, name, val, trim_str, adjustl_str)

    implicit none

    class(json_core),intent(inout)                   :: json
    type(json_value),pointer                         :: p
    character(kind=CK,len=*),intent(in)              :: name        !! variable name
    character(kind=CK,len=*),dimension(:),intent(in) :: val         !! array of strings
    logical(LK),intent(in),optional                  :: trim_str    !! if TRIM() should be called for each element
    logical(LK),intent(in),optional                  :: adjustl_str !! if ADJUSTL() should be called for each element

    type(json_value),pointer :: var
    integer(IK) :: i  !! counter

    !create the variable as an array:
    call json%create_array(var,name)

    !populate the array:
    do i=1,size(val)
        call json%add(var, CK_'', val(i), trim_str, adjustl_str)
    end do

    !add it:
    call json%add(p, var)

    end subroutine json_value_add_string_vec