json_value_to_string Subroutine

private subroutine json_value_to_string(json, p, str)

Print the json_value structure to an allocatable string.

Type Bound

json_core

Arguments

Type IntentOptional Attributes Name
class(json_core), intent(inout) :: json
type(json_value), intent(in), pointer :: p
character(kind=CK, len=:), intent(out), allocatable :: str

prints structure to this string


Calls

proc~~json_value_to_string~~CallsGraph proc~json_value_to_string json_value_module::json_core%json_value_to_string proc~json_value_print json_value_module::json_core%json_value_print proc~json_value_to_string->proc~json_value_print proc~json_value_print->proc~json_value_print failed failed proc~json_value_print->failed proc~escape_string json_string_utilities::escape_string proc~json_value_print->proc~escape_string proc~integer_to_string json_string_utilities::integer_to_string proc~json_value_print->proc~integer_to_string proc~real_to_string json_string_utilities::real_to_string proc~json_value_print->proc~real_to_string throw_exception throw_exception proc~json_value_print->throw_exception proc~valid_json_hex json_string_utilities::valid_json_hex proc~escape_string->proc~valid_json_hex proc~compact_real_string json_string_utilities::compact_real_string proc~real_to_string->proc~compact_real_string

Contents

Source Code


Source Code

    subroutine json_value_to_string(json,p,str)

    implicit none

    class(json_core),intent(inout)                   :: json
    type(json_value),pointer,intent(in)              :: p
    character(kind=CK,len=:),intent(out),allocatable :: str  !! prints structure to this string

    integer(IK) :: iloc  !! used to keep track of size of str
                         !! since it is being allocated in chunks.

    str = repeat(space, print_str_chunk_size)
    iloc = 0_IK
    call json%json_value_print(p, iunit=unit2str, str=str, iloc=iloc, indent=1_IK, colon=.true.)

    ! trim the string if necessary:
    if (len(str)>iloc) str = str(1:iloc)

    end subroutine json_value_to_string