to_string Subroutine

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

Change the json_value variable to a string.

Modified

  • Izaak Beekman : 02/24/2015

Type Bound

json_core

Arguments

Type IntentOptional Attributes Name
class(json_core), intent(inout) :: json
type(json_value), pointer :: p
character(kind=CK, len=*), intent(in), optional :: val

if the value is also to be set (if not present, then ‘’ is used).

character(kind=CK, len=*), intent(in), optional :: name

if the name is also to be changed.

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

if TRIM() should be called for the val (only used if val is present)

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

if ADJUSTL() should be called for the val (only used if val is present) (note that ADJUSTL is done before TRIM)


Calls

proc~~to_string~~CallsGraph proc~to_string json_value_module::json_core%to_string proc~destroy_json_data json_value_module::destroy_json_data proc~to_string->proc~destroy_json_data

Called by

proc~~to_string~~CalledByGraph proc~to_string json_value_module::json_core%to_string proc~json_update_string json_value_module::json_core%json_update_string proc~json_update_string->proc~to_string none~add_by_path~2 json_value_module::json_core%add_by_path proc~json_update_string->none~add_by_path~2 proc~json_value_create_string json_value_module::json_core%json_value_create_string proc~json_value_create_string->proc~to_string proc~parse_value json_value_module::json_core%parse_value proc~parse_value->proc~to_string proc~parse_array json_value_module::json_core%parse_array proc~parse_value->proc~parse_array proc~parse_object json_value_module::json_core%parse_object proc~parse_value->proc~parse_object none~create_string json_value_module::json_core%create_string none~create_string->proc~json_value_create_string proc~wrap_json_value_create_string json_value_module::json_core%wrap_json_value_create_string none~create_string->proc~wrap_json_value_create_string proc~json_parse_file json_value_module::json_core%json_parse_file proc~json_parse_file->proc~parse_value proc~json_parse_string json_value_module::json_core%json_parse_string proc~json_parse_string->proc~parse_value proc~parse_array->proc~parse_value proc~parse_object->proc~parse_value proc~parse_object->proc~parse_object none~deserialize json_value_module::json_core%deserialize none~deserialize->proc~json_parse_string proc~wrap_json_parse_string json_value_module::json_core%wrap_json_parse_string none~deserialize->proc~wrap_json_parse_string none~load json_value_module::json_core%load none~load->proc~json_parse_file proc~json_add_string_by_path json_value_module::json_core%json_add_string_by_path proc~json_add_string_by_path->none~create_string proc~json_value_add_string json_value_module::json_core%json_value_add_string proc~json_value_add_string->none~create_string proc~wrap_json_value_create_string->none~create_string proc~json_add_string_by_path_path_ascii json_value_module::json_core%json_add_string_by_path_path_ascii proc~json_add_string_by_path_path_ascii->proc~json_add_string_by_path proc~json_add_string_by_path_value_ascii json_value_module::json_core%json_add_string_by_path_value_ascii proc~json_add_string_by_path_value_ascii->proc~json_add_string_by_path proc~json_file_load json_file_module::json_file%json_file_load proc~json_file_load->none~load proc~json_file_load_from_string json_file_module::json_file%json_file_load_from_string proc~json_file_load_from_string->none~deserialize proc~wrap_json_add_string_by_path json_value_module::json_core%wrap_json_add_string_by_path proc~wrap_json_add_string_by_path->proc~json_add_string_by_path proc~wrap_json_parse_string->none~deserialize none~add_by_path~2->proc~json_add_string_by_path_path_ascii none~add_by_path~2->proc~json_add_string_by_path_value_ascii none~deserialize~2 json_file_module::json_file%deserialize none~deserialize~2->proc~json_file_load_from_string proc~wrap_json_file_load_from_string json_file_module::json_file%wrap_json_file_load_from_string none~deserialize~2->proc~wrap_json_file_load_from_string proc~assign_string_to_json_file json_file_module::json_file%assign_string_to_json_file proc~assign_string_to_json_file->none~deserialize~2 proc~initialize_json_file_from_string json_file_module::initialize_json_file_from_string proc~initialize_json_file_from_string->none~deserialize~2 proc~initialize_json_file_from_string_v2 json_file_module::initialize_json_file_from_string_v2 proc~initialize_json_file_from_string_v2->none~deserialize~2 proc~json_add_real32_by_path json_value_module::json_core%json_add_real32_by_path proc~json_add_real32_by_path->none~add_by_path~2 proc~json_add_real32_vec_by_path json_value_module::json_core%json_add_real32_vec_by_path proc~json_add_real32_vec_by_path->none~add_by_path~2 proc~json_file_add_integer json_file_module::json_file%json_file_add_integer proc~json_file_add_integer->none~add_by_path~2 proc~json_file_add_integer_vec json_file_module::json_file%json_file_add_integer_vec proc~json_file_add_integer_vec->none~add_by_path~2 proc~json_file_add_logical json_file_module::json_file%json_file_add_logical proc~json_file_add_logical->none~add_by_path~2 proc~json_file_add_logical_vec json_file_module::json_file%json_file_add_logical_vec proc~json_file_add_logical_vec->none~add_by_path~2 proc~json_file_add_object json_file_module::json_file%json_file_add_object proc~json_file_add_object->none~add_by_path~2 proc~json_file_add_real json_file_module::json_file%json_file_add_real proc~json_file_add_real->none~add_by_path~2 proc~json_file_add_real32 json_file_module::json_file%json_file_add_real32 proc~json_file_add_real32->none~add_by_path~2 proc~json_file_add_real32_vec json_file_module::json_file%json_file_add_real32_vec proc~json_file_add_real32_vec->none~add_by_path~2 proc~json_file_add_real_vec json_file_module::json_file%json_file_add_real_vec proc~json_file_add_real_vec->none~add_by_path~2 proc~json_file_add_string json_file_module::json_file%json_file_add_string proc~json_file_add_string->none~add_by_path~2 proc~json_file_add_string_vec json_file_module::json_file%json_file_add_string_vec proc~json_file_add_string_vec->none~add_by_path~2 proc~json_update_integer json_value_module::json_core%json_update_integer proc~json_update_integer->none~add_by_path~2 proc~json_update_logical json_value_module::json_core%json_update_logical proc~json_update_logical->none~add_by_path~2 proc~json_update_real json_value_module::json_core%json_update_real proc~json_update_real->none~add_by_path~2 proc~wrap_json_add_real32_by_path json_value_module::json_core%wrap_json_add_real32_by_path proc~wrap_json_add_real32_by_path->none~add_by_path~2 proc~wrap_json_add_real32_vec_by_path json_value_module::json_core%wrap_json_add_real32_vec_by_path proc~wrap_json_add_real32_vec_by_path->none~add_by_path~2 proc~wrap_json_file_load_from_string->none~deserialize~2 interface~json_file json_file_module::json_file interface~json_file->proc~initialize_json_file_from_string interface~json_file->proc~initialize_json_file_from_string_v2 proc~wrap_initialize_json_file_from_string json_file_module::wrap_initialize_json_file_from_string interface~json_file->proc~wrap_initialize_json_file_from_string proc~wrap_initialize_json_file_from_string_v2 json_file_module::wrap_initialize_json_file_from_string_v2 interface~json_file->proc~wrap_initialize_json_file_from_string_v2 proc~json_file_add_string_path_ascii json_file_module::json_file%json_file_add_string_path_ascii proc~json_file_add_string_path_ascii->proc~json_file_add_string proc~json_file_add_string_value_ascii json_file_module::json_file%json_file_add_string_value_ascii proc~json_file_add_string_value_ascii->proc~json_file_add_string proc~json_file_add_string_vec_path_ascii json_file_module::json_file%json_file_add_string_vec_path_ascii proc~json_file_add_string_vec_path_ascii->proc~json_file_add_string_vec proc~json_file_add_string_vec_vec_ascii json_file_module::json_file%json_file_add_string_vec_vec_ascii proc~json_file_add_string_vec_vec_ascii->proc~json_file_add_string_vec proc~wrap_assign_string_to_json_file json_file_module::json_file%wrap_assign_string_to_json_file proc~wrap_assign_string_to_json_file->proc~assign_string_to_json_file proc~wrap_initialize_json_file_from_string->proc~initialize_json_file_from_string proc~wrap_initialize_json_file_from_string_v2->proc~initialize_json_file_from_string_v2 proc~wrap_json_file_add_integer json_file_module::json_file%wrap_json_file_add_integer proc~wrap_json_file_add_integer->proc~json_file_add_integer proc~wrap_json_file_add_integer_vec json_file_module::json_file%wrap_json_file_add_integer_vec proc~wrap_json_file_add_integer_vec->proc~json_file_add_integer_vec proc~wrap_json_file_add_logical json_file_module::json_file%wrap_json_file_add_logical proc~wrap_json_file_add_logical->proc~json_file_add_logical proc~wrap_json_file_add_logical_vec json_file_module::json_file%wrap_json_file_add_logical_vec proc~wrap_json_file_add_logical_vec->proc~json_file_add_logical_vec proc~wrap_json_file_add_object json_file_module::json_file%wrap_json_file_add_object proc~wrap_json_file_add_object->proc~json_file_add_object proc~wrap_json_file_add_real json_file_module::json_file%wrap_json_file_add_real proc~wrap_json_file_add_real->proc~json_file_add_real proc~wrap_json_file_add_real32 json_file_module::json_file%wrap_json_file_add_real32 proc~wrap_json_file_add_real32->proc~json_file_add_real32 proc~wrap_json_file_add_real32_vec json_file_module::json_file%wrap_json_file_add_real32_vec proc~wrap_json_file_add_real32_vec->proc~json_file_add_real32_vec proc~wrap_json_file_add_real_vec json_file_module::json_file%wrap_json_file_add_real_vec proc~wrap_json_file_add_real_vec->proc~json_file_add_real_vec proc~wrap_json_file_add_string json_file_module::json_file%wrap_json_file_add_string proc~wrap_json_file_add_string->proc~json_file_add_string proc~wrap_json_file_add_string_vec json_file_module::json_file%wrap_json_file_add_string_vec proc~wrap_json_file_add_string_vec->proc~json_file_add_string_vec

Source Code

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

    implicit none

    class(json_core),intent(inout)  :: json
    type(json_value),pointer        :: p
    character(kind=CK,len=*),intent(in),optional :: val   !! if the value is also to be set
                                                          !! (if not present, then '' is used).
    character(kind=CK,len=*),intent(in),optional :: name  !! if the name is also to be changed.
    logical(LK),intent(in),optional     :: trim_str       !! if TRIM() should be called for the `val`
                                                          !! (only used if `val` is present)
    logical(LK),intent(in),optional     :: adjustl_str    !! if ADJUSTL() should be called for the `val`
                                                          !! (only used if `val` is present)
                                                          !! (note that ADJUSTL is done before TRIM)

    character(kind=CK,len=:),allocatable :: str !! temp string for `trim()` and/or `adjustl()`
    logical :: trim_string    !! if the string is to be trimmed
    logical :: adjustl_string !! if the string is to be adjusted left

    !set type and value:
    call destroy_json_data(p)
    p%var_type = json_string
    if (present(val)) then

        if (present(trim_str)) then
            trim_string = trim_str
        else
            trim_string = .false.
        end if
        if (present(adjustl_str)) then
            adjustl_string = adjustl_str
        else
            adjustl_string = .false.
        end if

        if (trim_string .or. adjustl_string) then
            str = val
            if (adjustl_string) str = adjustl(str)
            if (trim_string)    str = trim(str)
            p%str_value = str
        else
            p%str_value = val
        end if

    else
        p%str_value = CK_''  ! default value
    end if

    !name:
    if (present(name)) call json%rename(p,name)

    end subroutine to_string