json_file Derived Type

type, public :: json_file

Constructor

public interface json_file

  • private function initialize_json_file(p, verbose, compact_reals, print_signs, real_format, spaces_per_tab, strict_type_checking, trailing_spaces_significant, case_sensitive_keys) result(file_object)

    Arguments

    Type IntentOptional AttributesName
    type(json_value), intent(in), optional pointer:: p

    json_value object to cast as a json_file object

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

    mainly useful for debugging (default is false)

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

    to compact the real number strings for output (default is true)

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

    always print numeric sign (default is false)

    character(kind=CDK,len=*), intent(in), optional :: real_format

    Real number format: 'E' [default], '*', 'G', 'EN', or 'ES'

    integer(kind=IK), intent(in), optional :: spaces_per_tab

    number of spaces per tab for indenting (default is 2)

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

    if true, no integer, double, or logical type conversions are done for the get routines (default is false)

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

    for name and path comparisons, is trailing space to be considered significant.

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

    for name and path comparisons, are they case sensitive.

    Return Value type(json_file)

  • private function initialize_json_file_v2(json_value_object, json_core_object) result(file_object)

    Arguments

    Type IntentOptional AttributesName
    type(json_value), intent(in), pointer:: json_value_object
    type(json_core), intent(in) :: json_core_object

    Return Value type(json_file)


Type-Bound Procedures

procedure, public :: initialize => initialize_json_core_in_file

  • private subroutine initialize_json_core_in_file(me, verbose, compact_reals, print_signs, real_format, spaces_per_tab, strict_type_checking, trailing_spaces_significant, case_sensitive_keys)

    Arguments

    Type IntentOptional AttributesName
    class(json_file), intent(inout) :: me
    logical(kind=LK), intent(in), optional :: verbose

    mainly useful for debugging (default is false)

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

    to compact the real number strings for output (default is true)

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

    always print numeric sign (default is false)

    character(kind=CDK,len=*), intent(in), optional :: real_format

    Real number format: 'E' [default], '*', 'G', 'EN', or 'ES'

    integer(kind=IK), intent(in), optional :: spaces_per_tab

    number of spaces per tab for indenting (default is 2)

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

    if true, no integer, double, or logical type conversions are done for the get routines (default is false)

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

    for name and path comparisons, is trailing space to be considered significant.

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

    for name and path comparisons, are they case sensitive.

procedure, public :: load_file => json_file_load

  • private subroutine json_file_load(me, filename, unit)

    Arguments

    Type IntentOptional AttributesName
    class(json_file), intent(inout) :: me
    character(kind=CDK,len=*), intent(in) :: filename

    the filename to open

    integer(kind=IK), intent(in), optional :: unit

    the unit number to use (if not present, a newunit is used)

generic, public :: load_from_string => json_file_load_from_string

  • private subroutine json_file_load_from_string(me, str)

    Arguments

    Type IntentOptional AttributesName
    class(json_file), intent(inout) :: me
    character(kind=CK,len=*), intent(in) :: str

    string to load JSON data from

procedure, public :: destroy => json_file_destroy

  • private subroutine json_file_destroy(me, destroy_core)

    Arguments

    Type IntentOptional AttributesName
    class(json_file), intent(inout) :: me
    logical, intent(in), optional :: destroy_core

    to also destroy the json_core. default is to leave it as is.

procedure, public :: move => json_file_move_pointer

  • private subroutine json_file_move_pointer(to, from)

    Arguments

    Type IntentOptional AttributesName
    class(json_file), intent(inout) :: to
    class(json_file), intent(inout) :: from

generic, public :: info => json_file_variable_info

  • private subroutine json_file_variable_info(me, path, found, var_type, n_children)

    Arguments

    Type IntentOptional AttributesName
    class(json_file), intent(inout) :: me
    character(kind=CK,len=*), intent(in) :: path

    path to the variable

    logical(kind=LK), intent(out) :: found

    the variable exists in the structure

    integer(kind=IK), intent(out) :: var_type

    variable type

    integer(kind=IK), intent(out) :: n_children

    number of children

procedure, public :: failed => json_file_failed

  • private pure function json_file_failed(me) result(failed)

    Arguments

    Type IntentOptional AttributesName
    class(json_file), intent(in) :: me

    Return Value logical(kind=LK)

    will be true if there has been an error.

procedure, public :: print_error_message => json_file_print_error_message

  • private subroutine json_file_print_error_message(me, io_unit)

    Arguments

    Type IntentOptional AttributesName
    class(json_file), intent(inout) :: me
    integer, intent(in), optional :: io_unit

procedure, public :: check_for_errors => json_file_check_for_errors

  • private subroutine json_file_check_for_errors(me, status_ok, error_msg)

    Arguments

    Type IntentOptional AttributesName
    class(json_file), intent(inout) :: me
    logical(kind=LK), intent(out) :: status_ok

    true if there were no errors

    character(kind=CK,len=:), intent(out), allocatable:: error_msg

    the error message (if there were errors)

procedure, public :: clear_exceptions => json_file_clear_exceptions

  • private pure subroutine json_file_clear_exceptions(me)

    Arguments

    Type IntentOptional AttributesName
    class(json_file), intent(inout) :: me

procedure, public :: print_to_string => json_file_print_to_string

  • private subroutine json_file_print_to_string(me, str)

    Arguments

    Type IntentOptional AttributesName
    class(json_file), intent(inout) :: me
    character(kind=CK,len=:), intent(out), allocatable:: str

    string to print JSON data to

  • private subroutine json_file_print_to_console(me)

    Arguments

    Type IntentOptional AttributesName
    class(json_file), intent(inout) :: me
  • private subroutine json_file_print_1(me, iunit)

    Arguments

    Type IntentOptional AttributesName
    class(json_file), intent(inout) :: me
    integer(kind=IK), intent(in) :: iunit

    file unit number (must not be -1)

  • private subroutine json_file_print_2(me, filename)

    Arguments

    Type IntentOptional AttributesName
    class(json_file), intent(inout) :: me
    character(kind=CDK,len=*), intent(in) :: filename

    filename to print to

  • private subroutine json_file_get_object(me, path, p, found)

    Arguments

    Type IntentOptional AttributesName
    class(json_file), intent(inout) :: me
    character(kind=CK,len=*), intent(in) :: path

    the path to the variable

    type(json_value), intent(out), pointer:: p

    pointer to the variable

    logical(kind=LK), intent(out), optional :: found

    if it was really found

  • private subroutine json_file_get_integer(me, path, val, found)

    Arguments

    Type IntentOptional AttributesName
    class(json_file), intent(inout) :: me
    character(kind=CK,len=*), intent(in) :: path

    the path to the variable

    integer(kind=IK), intent(out) :: val

    value

    logical(kind=LK), intent(out), optional :: found

    if it was really found

  • private subroutine json_file_get_double(me, path, val, found)

    Arguments

    Type IntentOptional AttributesName
    class(json_file), intent(inout) :: me
    character(kind=CK,len=*), intent(in) :: path
    real(kind=RK), intent(out) :: val
    logical(kind=LK), intent(out), optional :: found
  • private subroutine json_file_get_logical(me, path, val, found)

    Arguments

    Type IntentOptional AttributesName
    class(json_file), intent(inout) :: me
    character(kind=CK,len=*), intent(in) :: path
    logical(kind=LK), intent(out) :: val
    logical(kind=LK), intent(out), optional :: found
  • private subroutine json_file_get_string(me, path, val, found)

    Arguments

    Type IntentOptional AttributesName
    class(json_file), intent(inout) :: me
    character(kind=CK,len=*), intent(in) :: path
    character(kind=CK,len=:), intent(out), allocatable:: val
    logical(kind=LK), intent(out), optional :: found
  • private subroutine json_file_get_integer_vec(me, path, vec, found)

    Arguments

    Type IntentOptional AttributesName
    class(json_file), intent(inout) :: me
    character(kind=CK,len=*), intent(in) :: path

    the path to the variable

    integer(kind=IK), intent(out), dimension(:), allocatable:: vec

    the value vector

    logical(kind=LK), intent(out), optional :: found

    if it was really found

  • private subroutine json_file_get_double_vec(me, path, vec, found)

    Arguments

    Type IntentOptional AttributesName
    class(json_file), intent(inout) :: me
    character(kind=CK,len=*), intent(in) :: path
    real(kind=RK), intent(out), dimension(:), allocatable:: vec
    logical(kind=LK), intent(out), optional :: found
  • private subroutine json_file_get_logical_vec(me, path, vec, found)

    Arguments

    Type IntentOptional AttributesName
    class(json_file), intent(inout) :: me
    character(kind=CK,len=*), intent(in) :: path
    logical(kind=LK), intent(out), dimension(:), allocatable:: vec
    logical(kind=LK), intent(out), optional :: found
  • private subroutine json_file_get_string_vec(me, path, vec, found)

    Arguments

    Type IntentOptional AttributesName
    class(json_file), intent(inout) :: me
    character(kind=CK,len=*), intent(in) :: path
    character(kind=CK,len=*), intent(out), dimension(:), allocatable:: vec
    logical(kind=LK), intent(out), optional :: found
  • private subroutine json_file_get_root(me, p)

    Arguments

    Type IntentOptional AttributesName
    class(json_file), intent(inout) :: me
    type(json_value), intent(out), pointer:: p

    pointer to the variable

  • private subroutine json_file_update_integer(me, name, val, found)

    Arguments

    Type IntentOptional AttributesName
    class(json_file), intent(inout) :: me
    character(kind=CK,len=*), intent(in) :: name
    integer(kind=IK), intent(in) :: val
    logical(kind=LK), intent(out) :: found
  • private subroutine json_file_update_logical(me, name, val, found)

    Arguments

    Type IntentOptional AttributesName
    class(json_file), intent(inout) :: me
    character(kind=CK,len=*), intent(in) :: name
    logical(kind=LK), intent(in) :: val
    logical(kind=LK), intent(out) :: found
  • private subroutine json_file_update_real(me, name, val, found)

    Arguments

    Type IntentOptional AttributesName
    class(json_file), intent(inout) :: me
    character(kind=CK,len=*), intent(in) :: name
    real(kind=RK), intent(in) :: val
    logical(kind=LK), intent(out) :: found
  • private subroutine json_file_update_string(me, name, val, found)

    Arguments

    Type IntentOptional AttributesName
    class(json_file), intent(inout) :: me
    character(kind=CK,len=*), intent(in) :: name
    character(kind=CK,len=*), intent(in) :: val
    logical(kind=LK), intent(out) :: found

procedure, public :: json_file_load_from_string

  • private subroutine json_file_load_from_string(me, str)

    Arguments

    Type IntentOptional AttributesName
    class(json_file), intent(inout) :: me
    character(kind=CK,len=*), intent(in) :: str

    string to load JSON data from

procedure, public :: json_file_variable_info

  • private subroutine json_file_variable_info(me, path, found, var_type, n_children)

    Arguments

    Type IntentOptional AttributesName
    class(json_file), intent(inout) :: me
    character(kind=CK,len=*), intent(in) :: path

    path to the variable

    logical(kind=LK), intent(out) :: found

    the variable exists in the structure

    integer(kind=IK), intent(out) :: var_type

    variable type

    integer(kind=IK), intent(out) :: n_children

    number of children

procedure, public :: json_file_get_object

  • private subroutine json_file_get_object(me, path, p, found)

    Arguments

    Type IntentOptional AttributesName
    class(json_file), intent(inout) :: me
    character(kind=CK,len=*), intent(in) :: path

    the path to the variable

    type(json_value), intent(out), pointer:: p

    pointer to the variable

    logical(kind=LK), intent(out), optional :: found

    if it was really found

procedure, public :: json_file_get_integer

  • private subroutine json_file_get_integer(me, path, val, found)

    Arguments

    Type IntentOptional AttributesName
    class(json_file), intent(inout) :: me
    character(kind=CK,len=*), intent(in) :: path

    the path to the variable

    integer(kind=IK), intent(out) :: val

    value

    logical(kind=LK), intent(out), optional :: found

    if it was really found

procedure, public :: json_file_get_double

  • private subroutine json_file_get_double(me, path, val, found)

    Arguments

    Type IntentOptional AttributesName
    class(json_file), intent(inout) :: me
    character(kind=CK,len=*), intent(in) :: path
    real(kind=RK), intent(out) :: val
    logical(kind=LK), intent(out), optional :: found

procedure, public :: json_file_get_logical

  • private subroutine json_file_get_logical(me, path, val, found)

    Arguments

    Type IntentOptional AttributesName
    class(json_file), intent(inout) :: me
    character(kind=CK,len=*), intent(in) :: path
    logical(kind=LK), intent(out) :: val
    logical(kind=LK), intent(out), optional :: found

procedure, public :: json_file_get_string

  • private subroutine json_file_get_string(me, path, val, found)

    Arguments

    Type IntentOptional AttributesName
    class(json_file), intent(inout) :: me
    character(kind=CK,len=*), intent(in) :: path
    character(kind=CK,len=:), intent(out), allocatable:: val
    logical(kind=LK), intent(out), optional :: found

procedure, public :: json_file_get_integer_vec

  • private subroutine json_file_get_integer_vec(me, path, vec, found)

    Arguments

    Type IntentOptional AttributesName
    class(json_file), intent(inout) :: me
    character(kind=CK,len=*), intent(in) :: path

    the path to the variable

    integer(kind=IK), intent(out), dimension(:), allocatable:: vec

    the value vector

    logical(kind=LK), intent(out), optional :: found

    if it was really found

procedure, public :: json_file_get_double_vec

  • private subroutine json_file_get_double_vec(me, path, vec, found)

    Arguments

    Type IntentOptional AttributesName
    class(json_file), intent(inout) :: me
    character(kind=CK,len=*), intent(in) :: path
    real(kind=RK), intent(out), dimension(:), allocatable:: vec
    logical(kind=LK), intent(out), optional :: found

procedure, public :: json_file_get_logical_vec

  • private subroutine json_file_get_logical_vec(me, path, vec, found)

    Arguments

    Type IntentOptional AttributesName
    class(json_file), intent(inout) :: me
    character(kind=CK,len=*), intent(in) :: path
    logical(kind=LK), intent(out), dimension(:), allocatable:: vec
    logical(kind=LK), intent(out), optional :: found

procedure, public :: json_file_get_string_vec

  • private subroutine json_file_get_string_vec(me, path, vec, found)

    Arguments

    Type IntentOptional AttributesName
    class(json_file), intent(inout) :: me
    character(kind=CK,len=*), intent(in) :: path
    character(kind=CK,len=*), intent(out), dimension(:), allocatable:: vec
    logical(kind=LK), intent(out), optional :: found

procedure, public :: json_file_get_root

  • private subroutine json_file_get_root(me, p)

    Arguments

    Type IntentOptional AttributesName
    class(json_file), intent(inout) :: me
    type(json_value), intent(out), pointer:: p

    pointer to the variable

procedure, public :: json_file_update_integer

  • private subroutine json_file_update_integer(me, name, val, found)

    Arguments

    Type IntentOptional AttributesName
    class(json_file), intent(inout) :: me
    character(kind=CK,len=*), intent(in) :: name
    integer(kind=IK), intent(in) :: val
    logical(kind=LK), intent(out) :: found

procedure, public :: json_file_update_logical

  • private subroutine json_file_update_logical(me, name, val, found)

    Arguments

    Type IntentOptional AttributesName
    class(json_file), intent(inout) :: me
    character(kind=CK,len=*), intent(in) :: name
    logical(kind=LK), intent(in) :: val
    logical(kind=LK), intent(out) :: found

procedure, public :: json_file_update_real

  • private subroutine json_file_update_real(me, name, val, found)

    Arguments

    Type IntentOptional AttributesName
    class(json_file), intent(inout) :: me
    character(kind=CK,len=*), intent(in) :: name
    real(kind=RK), intent(in) :: val
    logical(kind=LK), intent(out) :: found

procedure, public :: json_file_update_string

  • private subroutine json_file_update_string(me, name, val, found)

    Arguments

    Type IntentOptional AttributesName
    class(json_file), intent(inout) :: me
    character(kind=CK,len=*), intent(in) :: name
    character(kind=CK,len=*), intent(in) :: val
    logical(kind=LK), intent(out) :: found

procedure, public :: json_file_print_to_console

  • private subroutine json_file_print_to_console(me)

    Arguments

    Type IntentOptional AttributesName
    class(json_file), intent(inout) :: me

procedure, public :: json_file_print_1

  • private subroutine json_file_print_1(me, iunit)

    Arguments

    Type IntentOptional AttributesName
    class(json_file), intent(inout) :: me
    integer(kind=IK), intent(in) :: iunit

    file unit number (must not be -1)

procedure, public :: json_file_print_2

  • private subroutine json_file_print_2(me, filename)

    Arguments

    Type IntentOptional AttributesName
    class(json_file), intent(inout) :: me
    character(kind=CDK,len=*), intent(in) :: filename

    filename to print to