json_core Derived Type

type, public :: json_core

To access the core routines for manipulation of json_value pointer variables. This class allows for thread safe use of the module.

Usage

    program test
     use json_module, wp=>json_RK
     implicit none
     type(json_core) :: json     !<--have to declare this
     type(json_value),pointer :: p
     call json%create_object(p,'')   !create the root
     call json%add(p,'year',1805)    !add some data
     call json%add(p,'value',1.0_wp) !add some data
     call json%print(p,'test.json')  !write it to a file
     call json%destroy(p)            !cleanup
    end program test

Inherited by

type~~json_core~~InheritedByGraph type~json_core json_core type~json_file json_file type~json_file->type~json_core core

Components

Type Visibility Attributes Name Initial
logical(kind=LK), private :: allow_comments = .true.

if true, any comments will be ignored when parsing a file. The comment tokens are defined by the comment_char character variable.

logical(kind=LK), private :: allow_duplicate_keys = .true.

If False, then after parsing, if any duplicate keys are found, an error is thrown. A call to json_value_validate will also check for duplicates. If True [default] then no special checks are done

logical(kind=LK), private :: allow_trailing_comma = .true.

Allow a single trailing comma in arrays and objects.

logical(kind=LK), private :: case_sensitive_keys = .true.

if name and path comparisons are case sensitive.

integer(kind=IK), private :: char_count = 0

character position in the current line

character(kind=CK, len=:), private, allocatable :: chunk

a chunk read from a stream file when use_unformatted_stream=True

character(kind=CK, len=:), private, allocatable :: comment_char

comment tokens when allow_comments is true. Examples: ‘!’ or ‘#’. Default is CK_'/!#'.

logical(kind=LK), private :: compact_real = .true.

to use the “compact” form of real numbers for output

logical(kind=LK), private :: compress_vectors = .false.

If true, then arrays of integers, nulls, reals, & logicals are printed all on one line. [Note: no_whitespace will override this option if necessary]

character(kind=CK, len=:), private, allocatable :: err_message

the error message. if exception_thrown=False then this variable is not allocated.

logical(kind=LK), private :: escape_solidus = .false.

If True then the solidus “/” is always escaped (“\/”) when serializing JSON. If False [default], then it is not escaped. Note that this option does not affect parsing (both escaped and unescaped versions are still valid in all cases).

logical(kind=LK), private :: exception_thrown = .false.

The error flag. Will be set to true when an error is thrown in the class. Many of the methods will check this and return immediately if it is true.

integer, private :: filesize = 0

the file size when when use_unformatted_stream=True

integer, private :: ichunk = 0

index in chunk for pop_char when use_unformatted_stream=True

integer(kind=IK), private :: ipos = 1

for allocatable strings: next character to read

logical(kind=LK), private :: is_verbose = .false.

if true, all exceptions are immediately printed to console.

integer(kind=IK), private :: line_count = 1

lines read counter

logical(kind=LK), private :: no_whitespace = .false.

when printing a JSON string, don’t include non-significant spaces or line breaks. If true, the entire structure will be printed on one line.

logical(kind=LK), private :: non_normals_to_null = .false.

How to serialize NaN, Infinity, and -Infinity real values:

  • If true : as JSON null values
  • If false : as strings (e.g., “NaN”, “Infinity”, “-Infinity”) [default]
integer(kind=IK), private :: null_to_real_mode = 2_IK

if strict_type_checking=false:

  • 1 : an exception will be raised if try to retrieve a null as a real.
  • 2 : a null retrieved as a real will return NaN. [default]
  • 3 : a null retrieved as a real will return 0.0.
integer(kind=IK), private :: path_mode = 1_IK

How the path strings are interpreted in the get_by_path routines:

character(kind=CK, len=1), private :: path_separator = dot

The path separator to use in the “default” mode for the paths in the various get_by_path routines. Note: if path_mode/=1 then this is ignored.

character(kind=CK, len=pushed_char_size), private :: pushed_char = CK_''

used when parsing lines in file

integer(kind=IK), private :: pushed_index = 0

used when parsing lines in file

character(kind=CDK, len=:), private, allocatable :: real_fmt

the format string to use for converting real numbers to strings. It can be set in json_initialize, and used in json_value_print If not set, then default_real_fmt is used instead.

integer(kind=IK), private :: spaces_per_tab = 2

number of spaces for indenting

logical(kind=LK), private :: stop_on_error = .false.

if true, then the program is stopped immediately when an exception is raised.

logical(kind=LK), private :: strict_integer_type_checking = .true.
  • If false, when parsing JSON, if an integer numeric value cannot be converted to an integer (integer(IK)), then an attempt is then make to convert it to a real (real(RK)).
  • If true [default], an exception will be raised if an integer value cannot be read when parsing JSON.
logical(kind=LK), private :: strict_type_checking = .false.

if true, then no type conversions are done in the get routines if the actual variable type is different from the return type (for example, integer to real).

logical(kind=LK), private :: trailing_spaces_significant = .false.

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

logical(kind=LK), private :: unescaped_strings = .true.

If false, then the escaped string is returned from json_get_string and similar routines. If true [default], then the string is returned unescaped.

logical(kind=LK), private :: use_quiet_nan = .true.

if true [default], null_to_real_mode=2 and string_to_real will use ieee_quiet_nan for NaN values. If false, ieee_signaling_nan will be used.


Constructor

public interface json_core

Structure constructor to initialize a json_core object

Example

 type(json_file)  :: json_core
 json_core = json_core()
  • private function initialize_json_core(verbose, compact_reals, print_signs, real_format, spaces_per_tab, strict_type_checking, trailing_spaces_significant, case_sensitive_keys, no_whitespace, unescape_strings, comment_char, path_mode, path_separator, compress_vectors, allow_duplicate_keys, escape_solidus, stop_on_error, null_to_real_mode, non_normal_mode, use_quiet_nan, strict_integer_type_checking, allow_trailing_comma) result(json_core_object)

    Author
    Jacob Williams
    Date
    4/26/2016

    Function constructor for a json_core. This is just a wrapper for json_initialize.

    Arguments

    Type IntentOptional Attributes Name
    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. (default is false)

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

    for name and path comparisons, are they case sensitive. (default is true)

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

    if true, printing the JSON structure is done without adding any non-significant spaces or linebreaks (default is false)

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

    If false, then the raw escaped string is returned from json_get_string and similar routines. If true [default], then the string is returned unescaped.

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

    If present, these characters are used to denote comments in the JSON file, which will be ignored if present. Example: !, #, or /!#. Setting this to a blank string disables the ignoring of comments. (Default is /!#).

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

    How the path strings are interpreted in the get_by_path routines:

    Read more…
    character(kind=CK, len=1), intent(in), optional :: path_separator

    The path separator to use in the “default” mode for the paths in the various get_by_path routines. Example: . [default] or %. Note: if path_mode/=1 then this is ignored.

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

    If true, then arrays of integers, nulls, doubles, and logicals are printed all on one line. [Note: no_whitespace will override this option if necessary]. (Default is False).

    logical(kind=LK), intent(in), optional :: allow_duplicate_keys Read more…
    logical(kind=LK), intent(in), optional :: escape_solidus

    Note that this option does not affect parsing (both escaped and unescaped are still valid in all cases).

    Read more…
    logical(kind=LK), intent(in), optional :: stop_on_error

    If an exception is raised, then immediately quit. (Default is False).

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

    if strict_type_checking=false:

    Read more…
    integer(kind=IK), intent(in), optional :: non_normal_mode

    How to serialize NaN, Infinity, and -Infinity real values:

    Read more…
    logical(kind=LK), intent(in), optional :: use_quiet_nan Read more…
    logical(kind=LK), intent(in), optional :: strict_integer_type_checking

    (default is true)

    Read more…
    logical(kind=LK), intent(in), optional :: allow_trailing_comma

    Allow a single trailing comma in arrays and objects. (default is true)

    Return Value type(json_core)


Type-Bound Procedures

Add objects to a linked list of json_values.

Note

It might make more sense to call this add_child.

  • private subroutine json_value_add_member(json, p, member)

    Adds member as a child of p.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: p

    p must be a json_object or a json_array

    type(json_value), pointer :: member

    the child member to add to p

  • private subroutine json_value_add_null(json, p, name)

    Add a NULL value child to the json_value variable.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: p
    character(kind=CK, len=*), intent(in) :: name
  • private subroutine wrap_json_value_add_null(json, p, name)

    Alternate version of json_value_add_null where name is kind=CDK.

    Arguments

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

    name of the variable

  • private subroutine json_value_add_integer(json, p, name, val)

    Author
    Jacob Williams
    Date
    1/20/2014

    Add an integer value child to the json_value variable.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: p
    character(kind=CK, len=*), intent(in) :: name
    integer(kind=IK), intent(in) :: val
  • private subroutine wrap_json_value_add_integer(json, p, name, val)

    Alternate version of json_value_add_integer where name is kind=CDK.

    Arguments

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

    name of the variable

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

    value

  • private subroutine json_value_add_integer_vec(json, p, name, val)

    Author
    Jacob Williams
    Date
    1/20/2014

    Add a integer vector child to the json_value variable.

    Read more…

    Arguments

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

    name of the variable

    integer(kind=IK), intent(in), dimension(:) :: val

    value

  • private subroutine wrap_json_value_add_integer_vec(json, p, name, val)

    Alternate version of json_value_add_integer_vec where name is kind=CDK.

    Arguments

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

    name of the variable

    integer(kind=IK), intent(in), dimension(:) :: val

    value

  • private subroutine json_value_add_real32(json, p, name, val)

    Alternate version of json_value_add_real where val is real32.

    Arguments

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

    variable name

    real(kind=real32), intent(in) :: val

    real value

  • private subroutine wrap_json_value_add_real32(json, p, name, val)

    Alternate version of json_value_add_real32 where name is kind=CDK.

    Arguments

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

    variable name

    real(kind=real32), intent(in) :: val

    real value

  • private subroutine json_value_add_real32_vec(json, p, name, val)

    Alternate version of json_value_add_real_vec where val is real32.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: p
    character(kind=CK, len=*), intent(in) :: name
    real(kind=real32), intent(in), dimension(:) :: val
  • private subroutine wrap_json_value_add_real32_vec(json, p, name, val)

    Alternate version of json_value_add_real32_vec where name is kind=CDK.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: p
    character(kind=CDK, len=*), intent(in) :: name
    real(kind=real32), intent(in), dimension(:) :: val
  • private subroutine json_value_add_real(json, p, name, val)

    Author
    Jacob Williams
    Date
    1/19/2014

    Add a real value child to the json_value variable.

    Read more…

    Arguments

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

    variable name

    real(kind=RK), intent(in) :: val

    real value

  • private subroutine wrap_json_value_add_real(json, p, name, val)

    Alternate version of json_value_add_real where name is kind=CDK.

    Arguments

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

    variable name

    real(kind=RK), intent(in) :: val

    real value

  • private subroutine json_value_add_real_vec(json, p, name, val)

    Author
    Jacob Williams
    Date
    1/20/2014

    Add a real vector child to the json_value variable.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: p
    character(kind=CK, len=*), intent(in) :: name
    real(kind=RK), intent(in), dimension(:) :: val
  • private subroutine wrap_json_value_add_real_vec(json, p, name, val)

    Alternate version of json_value_add_real_vec where name is kind=CDK.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: p
    character(kind=CDK, len=*), intent(in) :: name
    real(kind=RK), intent(in), dimension(:) :: val
  • private subroutine json_value_add_logical(json, p, name, val)

    Author
    Jacob Williams
    Date
    1/20/2014

    Add a logical value child to the json_value variable.

    Read more…

    Arguments

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

    name of the variable

    logical(kind=LK), intent(in) :: val

    value

  • private subroutine wrap_json_value_add_logical(json, p, name, val)

    Alternate version of json_value_add_logical where name is kind=CDK.

    Arguments

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

    name of the variable

    logical(kind=LK), intent(in) :: val

    value

  • private subroutine json_value_add_logical_vec(json, p, name, val)

    Author
    Jacob Williams
    Date
    1/20/2014

    Add a logical vector child to the json_value variable.

    Read more…

    Arguments

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

    name of the vector

    logical(kind=LK), intent(in), dimension(:) :: val

    value

  • private subroutine wrap_json_value_add_logical_vec(json, p, name, val)

    Alternate version of json_value_add_logical_vec where name is kind=CDK.

    Arguments

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

    name of the variable

    logical(kind=LK), intent(in), dimension(:) :: val

    value

  • private subroutine json_value_add_string(json, p, name, val, trim_str, adjustl_str)

    Author
    Jacob Williams
    Date
    1/19/2014

    Add a character string child to the json_value variable.

    Read more…

    Arguments

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

    name of the variable

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

    value

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

    if TRIM() should be called for the val

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

    if ADJUSTL() should be called for the val

  • private subroutine wrap_json_value_add_string(json, p, name, val, trim_str, adjustl_str)

    Alternate version of json_value_add_string where name and val are kind=CDK.

    Arguments

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

    name of the variable

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

    value

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

    if TRIM() should be called for the val

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

    if ADJUSTL() should be called for the val

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

    Author
    Jacob Williams
    Date
    1/19/2014

    Add a character string vector child to the json_value variable.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    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

  • private subroutine wrap_json_value_add_string_vec(json, p, name, val, trim_str, adjustl_str)

    Alternate version of json_value_add_string_vec where name and val are kind=CDK.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: p
    character(kind=CDK, len=*), intent(in) :: name
    character(kind=CDK, len=*), intent(in), dimension(:) :: val
    logical(kind=LK), intent(in), optional :: trim_str
    logical(kind=LK), intent(in), optional :: adjustl_str
  • private subroutine json_value_add_string_name_ascii(json, p, name, val, trim_str, adjustl_str)

    Alternate version of json_value_add_string where name is kind=CDK.

    Arguments

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

    name of the variable

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

    value

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

    if TRIM() should be called for the val

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

    if ADJUSTL() should be called for the val

  • private subroutine json_value_add_string_val_ascii(json, p, name, val, trim_str, adjustl_str)

    Alternate version of json_value_add_string where val is kind=CDK.

    Arguments

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

    name of the variable

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

    value

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

    if TRIM() should be called for the val

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

    if ADJUSTL() should be called for the val

  • private subroutine json_value_add_string_vec_name_ascii(json, p, name, val, trim_str, adjustl_str)

    Alternate version of json_value_add_string_vec where name is kind=CDK.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: p
    character(kind=CDK, len=*), intent(in) :: name
    character(kind=CK, len=*), intent(in), dimension(:) :: val
    logical(kind=LK), intent(in), optional :: trim_str
    logical(kind=LK), intent(in), optional :: adjustl_str
  • private subroutine json_value_add_string_vec_val_ascii(json, p, name, val, trim_str, adjustl_str)

    Alternate version of json_value_add_string_vec where val is kind=CDK.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: p
    character(kind=CK, len=*), intent(in) :: name
    character(kind=CDK, len=*), intent(in), dimension(:) :: val
    logical(kind=LK), intent(in), optional :: trim_str
    logical(kind=LK), intent(in), optional :: adjustl_str

Add variables to a json_value linked list by specifying their paths.

Example

    use, intrinsic :: iso_fortran_env, only: output_unit
    use json_module, wp=>json_RK
    type(json_core) :: json
    type(json_value) :: p
    call json%create_object(p,'root') ! create the root
    ! now add some variables using the paths:
    call json%add_by_path(p,'inputs.t',    0.0_wp  )
    call json%add_by_path(p,'inputs.x(1)', 100.0_wp)
    call json%add_by_path(p,'inputs.x(2)', 200.0_wp)
    call json%print(p)  ! now print to console

Notes

See also

  • private subroutine json_add_member_by_path(json, me, path, p, found, was_created)

    Add a new member (json_value pointer) to a JSON structure, given the path.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: me

    the JSON structure

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

    the path to the variable

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

    the value to add

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

    if the variable was found

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

    if the variable had to be created

  • private subroutine wrap_json_add_member_by_path(json, me, path, p, found, was_created)

    Wrapper to json_add_member_by_path where “path” is kind=CDK.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: me

    the JSON structure

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

    the path to the variable

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

    the value to add

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

    if the variable was found

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

    if the variable had to be created

  • private subroutine json_add_integer_by_path(json, me, path, value, found, was_created)

    Add an integer value to a json_value, given the path.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: me

    the JSON structure

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

    the path to the variable

    integer(kind=IK), intent(in) :: value

    the value to add

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

    if the variable was found

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

    if the variable had to be created

  • private subroutine wrap_json_add_integer_by_path(json, me, path, value, found, was_created)

    Wrapper to json_add_integer_by_path where “path” is kind=CDK.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: me

    the JSON structure

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

    the path to the variable

    integer(kind=IK), intent(in) :: value

    the value to add

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

    if the variable was found

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

    if the variable had to be created

  • private subroutine json_add_real32_by_path(json, me, path, value, found, was_created)

    Alternate version of json_add_real_by_path where value=real32.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: me

    the JSON structure

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

    the path to the variable

    real(kind=real32), intent(in) :: value

    the value to add

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

    if the variable was found

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

    if the variable had to be created

  • private subroutine wrap_json_add_real32_by_path(json, me, path, value, found, was_created)

    Wrapper to json_add_real32_by_path where “path” is kind=CDK.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: me

    the JSON structure

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

    the path to the variable

    real(kind=real32), intent(in) :: value

    the value to add

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

    if the variable was found

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

    if the variable had to be created

  • private subroutine json_add_real_by_path(json, me, path, value, found, was_created)

    Add an real value to a json_value, given the path.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: me

    the JSON structure

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

    the path to the variable

    real(kind=RK), intent(in) :: value

    the value to add

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

    if the variable was found

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

    if the variable had to be created

  • private subroutine wrap_json_add_real_by_path(json, me, path, value, found, was_created)

    Wrapper to json_add_real_by_path where “path” is kind=CDK.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: me

    the JSON structure

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

    the path to the variable

    real(kind=RK), intent(in) :: value

    the value to add

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

    if the variable was found

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

    if the variable had to be created

  • private subroutine json_add_logical_by_path(json, me, path, value, found, was_created)

    Add a logical value to a json_value, given the path.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: me

    the JSON structure

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

    the path to the variable

    logical(kind=LK), intent(in) :: value

    the value to add

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

    if the variable was found

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

    if the variable had to be created

  • private subroutine wrap_json_add_logical_by_path(json, me, path, value, found, was_created)

    Wrapper to json_add_logical_by_path where “path” is kind=CDK.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: me

    the JSON structure

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

    the path to the variable

    logical(kind=LK), intent(in) :: value

    the value to add

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

    if the variable was found

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

    if the variable had to be created

  • private subroutine json_add_string_by_path(json, me, path, value, found, was_created, trim_str, adjustl_str)

    Add a string value to a json_value, given the path.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: me

    the JSON structure

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

    the path to the variable

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

    the value to add

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

    if the variable was found

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

    if the variable had to be created

    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

  • private subroutine wrap_json_add_string_by_path(json, me, path, value, found, was_created, trim_str, adjustl_str)

    Wrapper to json_add_string_by_path where “path” is kind=CDK.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: me

    the JSON structure

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

    the path to the variable

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

    the value to add

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

    if the variable was found

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

    if the variable had to be created

    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

  • private subroutine json_add_integer_vec_by_path(json, me, path, value, found, was_created)

    Wrapper to json_add_integer_by_path for adding an integer vector by path.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: me

    the JSON structure

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

    the path to the variable

    integer(kind=IK), intent(in), dimension(:) :: value

    the vector to add

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

    if the variable was found

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

    if the variable had to be created

  • private subroutine wrap_json_add_integer_vec_by_path(json, me, path, value, found, was_created)

    Wrapper for json_add_integer_vec_by_path where “path” is kind=CDK).

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: me

    the JSON structure

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

    the path to the variable

    integer(kind=IK), intent(in), dimension(:) :: value

    the vector to add

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

    if the variable was found

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

    if the variable had to be created

  • private subroutine json_add_real32_vec_by_path(json, me, path, value, found, was_created)

    Wrapper to json_add_real_by_path for adding a real vector by path.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: me

    the JSON structure

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

    the path to the variable

    real(kind=real32), intent(in), dimension(:) :: value

    the vector to add

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

    if the variable was found

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

    if the variable had to be created

  • private subroutine wrap_json_add_real32_vec_by_path(json, me, path, value, found, was_created)

    Wrapper for json_add_real32_vec_by_path where “path” is kind=CDK).

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: me

    the JSON structure

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

    the path to the variable

    real(kind=real32), intent(in), dimension(:) :: value

    the vector to add

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

    if the variable was found

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

    if the variable had to be created

  • private subroutine json_add_real_vec_by_path(json, me, path, value, found, was_created)

    Wrapper to json_add_real_by_path for adding a real vector by path.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: me

    the JSON structure

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

    the path to the variable

    real(kind=RK), intent(in), dimension(:) :: value

    the vector to add

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

    if the variable was found

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

    if the variable had to be created

  • private subroutine wrap_json_add_real_vec_by_path(json, me, path, value, found, was_created)

    Wrapper for json_add_real_vec_by_path where “path” is kind=CDK).

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: me

    the JSON structure

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

    the path to the variable

    real(kind=RK), intent(in), dimension(:) :: value

    the vector to add

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

    if the variable was found

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

    if the variable had to be created

  • private subroutine json_add_logical_vec_by_path(json, me, path, value, found, was_created)

    Wrapper to json_add_logical_by_path for adding a logical vector by path.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: me

    the JSON structure

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

    the path to the variable

    logical(kind=LK), intent(in), dimension(:) :: value

    the vector to add

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

    if the variable was found

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

    if the variable had to be created

  • private subroutine wrap_json_add_logical_vec_by_path(json, me, path, value, found, was_created)

    Wrapper for json_add_logical_vec_by_path where “path” is kind=CDK).

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: me

    the JSON structure

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

    the path to the variable

    logical(kind=LK), intent(in), dimension(:) :: value

    the vector to add

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

    if the variable was found

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

    if the variable had to be created

  • private subroutine json_add_string_vec_by_path(json, me, path, value, found, was_created, ilen, trim_str, adjustl_str)

    Wrapper to json_add_string_by_path for adding a string vector by path.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: me

    the JSON structure

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

    the path to the variable

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

    the vector to add

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

    if the variable was found

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

    if the variable had to be created

    integer(kind=IK), intent(in), optional, dimension(:) :: ilen

    the string lengths of each element in value. If not present, the full len(value) string is added for each element.

    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

  • private subroutine wrap_json_add_string_vec_by_path(json, me, path, value, found, was_created, ilen, trim_str, adjustl_str)

    Wrapper for json_add_string_vec_by_path where “path” and “value” are kind=CDK).

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: me

    the JSON structure

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

    the path to the variable

    character(kind=CDK, len=*), intent(in), dimension(:) :: value

    the vector to add

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

    if the variable was found

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

    if the variable had to be created

    integer(kind=IK), intent(in), optional, dimension(:) :: ilen

    the string lengths of each element in value. If not present, the full len(value) string is added for each element.

    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

  • private subroutine json_add_string_by_path_value_ascii(json, me, path, value, found, was_created, trim_str, adjustl_str)

    Wrapper for json_add_string_by_path where “value” is kind=CDK.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: me

    the JSON structure

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

    the path to the variable

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

    the value to add

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

    if the variable was found

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

    if the variable had to be created

    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

  • private subroutine json_add_string_by_path_path_ascii(json, me, path, value, found, was_created, trim_str, adjustl_str)

    Wrapper for json_add_string_by_path where “path” is kind=CDK.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: me

    the JSON structure

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

    the path to the variable

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

    the value to add

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

    if the variable was found

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

    if the variable had to be created

    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

  • private subroutine json_add_string_vec_by_path_value_ascii(json, me, path, value, found, was_created, ilen, trim_str, adjustl_str)

    Wrapper for json_add_string_vec_by_path where “value” is kind=CDK).

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: me

    the JSON structure

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

    the path to the variable

    character(kind=CDK, len=*), intent(in), dimension(:) :: value

    the vector to add

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

    if the variable was found

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

    if the variable had to be created

    integer(kind=IK), intent(in), optional, dimension(:) :: ilen

    the string lengths of each element in value. If not present, the full len(value) string is added for each element.

    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

  • private subroutine json_add_string_vec_by_path_path_ascii(json, me, path, value, found, was_created, ilen, trim_str, adjustl_str)

    Wrapper for json_add_string_vec_by_path where “path” is kind=CDK).

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: me

    the JSON structure

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

    the path to the variable

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

    the vector to add

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

    if the variable was found

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

    if the variable had to be created

    integer(kind=IK), intent(in), optional, dimension(:) :: ilen

    the string lengths of each element in value. If not present, the full len(value) string is added for each element.

    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

procedure, private :: annotate_invalid_json

  • private subroutine annotate_invalid_json(json, iunit, str)

    Generate a warning message if there was an error parsing a JSON file or string.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    integer(kind=IK), intent(in) :: iunit

    file unit number

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

    string with JSON data

procedure, public :: check_children_for_duplicate_keys => json_check_children_for_duplicate_keys

Check a json_value object’s children for duplicate keys

  • private subroutine json_check_children_for_duplicate_keys(json, p, has_duplicate, name, path)

    Author
    Jacob Williams
    Date
    8/25/2017

    Checks a JSON object for duplicate child names.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), intent(in), pointer :: p

    the object to search. If p is not a json_object, then has_duplicate will be false.

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

    true if there is at least two children have duplicate name values.

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

    the duplicate name (unallocated if no duplicate was found)

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

    the full path to the duplicate name (unallocated if no duplicate was found)

procedure, public :: check_for_duplicate_keys => json_check_all_for_duplicate_keys

Check entire JSON structure for duplicate keys (recursively)

  • private subroutine json_check_all_for_duplicate_keys(json, p, has_duplicate, name, path)

    Author
    Jacob Williams
    Date
    8/25/2017

    Checks a JSON structure for duplicate child names. This one recursively traverses the entire structure (calling json_check_children_for_duplicate_keys recursively for each element).

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), intent(in), pointer :: p

    the object to search. If p is not a json_object, then has_duplicate will be false.

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

    true if there is at least one duplicate name key anywhere in the structure.

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

    the duplicate name (unallocated if no duplicates were found)

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

    the full path to the duplicate name (unallocated if no duplicate was found)

procedure, public :: check_for_errors => json_check_for_errors

check for error and get error message

  • private subroutine json_check_for_errors(json, status_ok, error_msg)

    Author
    Jacob Williams
    Date
    12/4/2013

    Retrieve error code from the json_core. This should be called after parse to check for errors. If an error is thrown, before using the class again, json_initialize should be called to clean up before it is used again.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(in) :: json
    logical(kind=LK), intent(out), optional :: status_ok

    true if there were no errors

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

    the error message. (not allocated if there were no errors)

procedure, public :: clear_exceptions => json_clear_exceptions

clear exceptions

  • private pure subroutine json_clear_exceptions(json)

    Author
    Jacob Williams
    Date
    12/4/2013

    Clear exceptions in the json_core.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json

procedure, public :: clone => json_clone

clone a JSON structure (deep copy)

  • private subroutine json_clone(json, from, to)

    Author
    Jacob Williams
    Date
    10/31/2015

    Create a deep copy of a json_value linked-list structure.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: from

    this is the structure to clone

    type(json_value), pointer :: to

    the clone is put here (it must not already be associated)

procedure, private :: convert

  • private subroutine convert(json, p, var_type)

    Convert an existing JSON variable p to a different variable type. The existing variable (and its children) is destroyed. It is replaced in the structure by a new variable of type var_type (which can be a json_null, json_object or json_array).

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: p

    the variable to convert

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

    the variable type to convert p to

procedure, public :: count => json_count

count the number of children

  • private function json_count(json, p) result(count)

    Count the number of children in the object or array.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), intent(in), pointer :: p

    this should normally be a json_object or a json_array. For any other variable type this will return 0.

    Return Value integer(kind=IK)

    number of children in p.

generic, public :: create => json_create_by_path, wrap_json_create_by_path

Create a json_value linked list using the path to the variables. Optionally return a pointer to the variable.

(This will create a null variable)

See also

  • private subroutine json_create_by_path(json, me, path, p, found, was_created)

    Returns the json_value pointer given the path string, If necessary, by creating the variables as needed.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), intent(in), pointer :: me

    a JSON linked list

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

    path to the variable

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

    pointer to the variable specify by path

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

    true if there were no errors (variable found or created)

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

    true if it was actually created (as opposed to already being there)

  • private subroutine wrap_json_create_by_path(json, me, path, p, found, was_created)

    Alternate version of json_create_by_path where “path” is kind=CDK.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), intent(in), pointer :: me

    a JSON linked list

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

    path to the variable

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

    pointer to the variable specify by path

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

    true if there were no errors (variable found or created)

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

    true if it was actually created (as opposed to already being there)

generic, public :: create_array => json_value_create_array, wrap_json_value_create_array

Allocate a json_value pointer and make it an array variable. The pointer should not already be allocated.

Example

    type(json_core) :: json
    type(json_value),pointer :: p
    call json%create_array(p,'arrayname')
  • private subroutine json_value_create_array(json, p, name)

    Author
    Jacob Williams

    Allocate a json_value pointer and make it an array variable. The pointer should not already be allocated.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: p
    character(kind=CK, len=*), intent(in) :: name
  • private subroutine wrap_json_value_create_array(json, p, name)

    Author
    Izaak Beekman

    A wrapper for json_value_create_array so that create_array method may be called with an actual argument, corresponding to the dummy argument name, that is either of ‘DEFAULT’ or ‘ISO_10646’ character kind.

    Arguments

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

generic, public :: create_double => json_value_create_real, wrap_json_value_create_real

This is equivalent to create_real, and is here only for backward compatibility.

  • private subroutine json_value_create_real(json, p, val, name)

    Author
    Jacob Williams

    Allocate a json_value pointer and make it a real(RK) variable. The pointer should not already be allocated.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: p
    real(kind=RK), intent(in) :: val
    character(kind=CK, len=*), intent(in) :: name
  • private subroutine wrap_json_value_create_real(json, p, val, name)

    Author
    Izaak Beekman

    A wrapper for json_value_create_real so that create_real method may be called with an actual argument corresponding to the dummy argument, name that may be of ‘DEFAULT’ or ‘ISO_10646’ character kind.

    Arguments

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

generic, public :: create_double => json_value_create_real32, wrap_json_value_create_real32

generic, public :: create_integer => json_value_create_integer, wrap_json_value_create_integer

Allocate a json_value pointer and make it an integer variable. The pointer should not already be allocated.

Example

    type(json_core) :: json
    type(json_value),pointer :: p
    call json%create_integer(p,42,'value')
  • private subroutine json_value_create_integer(json, p, val, name)

    Author
    Jacob Williams

    Allocate a json_value pointer and make it an integer(IK) variable. The pointer should not already be allocated.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: p
    integer(kind=IK), intent(in) :: val
    character(kind=CK, len=*), intent(in) :: name
  • private subroutine wrap_json_value_create_integer(json, p, val, name)

    Author
    Izaak Beekman

    A wrapper procedure for json_value_create_integer so that create_integer method may be called with either a ‘DEFAULT’ or ‘ISO_10646’ character kind name actual argument.

    Arguments

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

generic, public :: create_logical => json_value_create_logical, wrap_json_value_create_logical

Allocate a json_value pointer and make it a logical variable. The pointer should not already be allocated.

Example

    type(json_core) :: json
    type(json_value),pointer :: p
    call json%create_logical(p,'value',.true.)
  • private subroutine json_value_create_logical(json, p, val, name)

    Author
    Jacob Williams

    Allocate a json_value pointer and make it a logical(LK) variable. The pointer should not already be allocated.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: p
    logical(kind=LK), intent(in) :: val

    variable value

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

    variable name

  • private subroutine wrap_json_value_create_logical(json, p, val, name)

    Author
    Izaak Beekman

    Wrapper for json_value_create_logical so create_logical method can be called with name of character kind ‘DEFAULT’ or ‘ISO_10646’

    Arguments

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

generic, public :: create_null => json_value_create_null, wrap_json_value_create_null

Allocate a json_value pointer and make it a null variable. The pointer should not already be allocated.

Example

    type(json_core) :: json
    type(json_value),pointer :: p
    call json%create_null(p,'value')
  • private subroutine json_value_create_null(json, p, name)

    Author
    Jacob Williams

    Allocate a json_value pointer and make it a null variable. The pointer should not already be allocated.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: p
    character(kind=CK, len=*), intent(in) :: name
  • private subroutine wrap_json_value_create_null(json, p, name)

    Author
    Izaak Beekman

    Wrap json_value_create_null so that create_null method may be called with an actual argument corresponding to the dummy argument name that is either of ‘DEFAULT’ or ‘ISO_10646’ character kind.

    Arguments

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

generic, public :: create_object => json_value_create_object, wrap_json_value_create_object

Allocate a json_value pointer and make it an object variable. The pointer should not already be allocated.

Example

    type(json_core) :: json
    type(json_value),pointer :: p
    call json%create_object(p,'objectname')

Note

The name is not significant for the root structure or an array element. In those cases, an empty string can be used.

  • private subroutine json_value_create_object(json, p, name)

    Author
    Jacob Williams

    Allocate a json_value pointer and make it an object variable. The pointer should not already be allocated.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: p
    character(kind=CK, len=*), intent(in) :: name
  • private subroutine wrap_json_value_create_object(json, p, name)

    Author
    Izaak Beekman

    Wrap json_value_create_object so that create_object method may be called with an actual argument corresponding to the dummy argument name that is of either ‘DEFAULT’ or ‘ISO_10646’ character kind.

    Arguments

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

generic, public :: create_real => json_value_create_real, wrap_json_value_create_real

Allocate a json_value pointer and make it a real variable. The pointer should not already be allocated.

Example

    type(json_core) :: json
    type(json_value),pointer :: p
    call json%create_real(p,'value',1.0_RK)

Note

  • create_real is just an alias to this one for backward compatibility.
  • private subroutine json_value_create_real(json, p, val, name)

    Author
    Jacob Williams

    Allocate a json_value pointer and make it a real(RK) variable. The pointer should not already be allocated.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: p
    real(kind=RK), intent(in) :: val
    character(kind=CK, len=*), intent(in) :: name
  • private subroutine wrap_json_value_create_real(json, p, val, name)

    Author
    Izaak Beekman

    A wrapper for json_value_create_real so that create_real method may be called with an actual argument corresponding to the dummy argument, name that may be of ‘DEFAULT’ or ‘ISO_10646’ character kind.

    Arguments

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

generic, public :: create_real => json_value_create_real32, wrap_json_value_create_real32

generic, public :: create_string => json_value_create_string, wrap_json_value_create_string

Allocate a json_value pointer and make it a string variable. The pointer should not already be allocated.

Example

    type(json_core) :: json
    type(json_value),pointer :: p
    call json%create_string(p,'value','foobar')
  • private subroutine json_value_create_string(json, p, val, name, trim_str, adjustl_str)

    Author
    Jacob Williams

    Allocate a json_value pointer and make it a string variable. The pointer should not already be allocated.

    Read more…

    Arguments

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

    if TRIM() should be called for the val

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

    if ADJUSTL() should be called for the val

  • private subroutine wrap_json_value_create_string(json, p, val, name, trim_str, adjustl_str)

    Author
    Izaak Beekman

    Wrap json_value_create_string so that create_string method may be called with actual character string arguments for name and val that are BOTH of ‘DEFAULT’ or ‘ISO_10646’ character kind.

    Arguments

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

    if TRIM() should be called for the val

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

    if ADJUSTL() should be called for the val

generic, public :: deserialize => json_parse_string, wrap_json_parse_string

Parse the JSON string and populate the json_value tree.

  • private subroutine json_parse_string(json, p, str)

    Parse the JSON string and populate the json_value tree.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: p

    output structure

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

    string with JSON data

  • private subroutine wrap_json_parse_string(json, p, str)

    Alternate version of json_parse_string, where str is kind=CDK.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: p

    output structure

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

    string with JSON data

generic, public :: destroy => json_value_destroy, destroy_json_core

Destructor routine for a json_value pointer. This must be called explicitly if it is no longer needed, before it goes out of scope. Otherwise, a memory leak will result.

Example

Destroy the json_value pointer before the variable goes out of scope:

     subroutine example1()
     type(json_core) :: json
     type(json_value),pointer :: p
     call json%create_object(p,'')
     call json%add(p,'year',2015)
     call json%print(p)
     call json%destroy(p)
     end subroutine example1

Note: it should NOT be called for a json_value pointer than has already been added to another json_value structure, since doing so may render the other structure invalid. Consider the following example:

     subroutine example2(p)
     type(json_core) :: json
     type(json_value),pointer,intent(out) :: p
     type(json_value),pointer :: q
     call json%create_object(p,'')
     call json%add(p,'year',2015)
     call json%create_object(q,'q')
     call json%add(q,'val',1)
     call json%add(p, q)  !add q to p structure
     ! do NOT call json%destroy(q) here, because q is
     ! now part of the output structure p.  p should be destroyed
     ! somewhere upstream by the caller of this routine.
     nullify(q) !OK, but not strictly necessary
     end subroutine example2
  • private pure recursive subroutine json_value_destroy(json, p, destroy_next)

    Author
    Jacob Williams
    Date
    1/22/2014

    Destroy a json_value linked-list structure.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: p

    variable to destroy

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

    if true, then p%next is also destroyed (default is true)

  • private subroutine destroy_json_core(me)

    Author
    Jacob Williams
    Date
    4/17/2016

    Destructor for the json_core type.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(out) :: me

procedure, private :: destroy_json_core

  • private subroutine destroy_json_core(me)

    Author
    Jacob Williams
    Date
    4/17/2016

    Destructor for the json_core type.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(out) :: me

procedure, public :: failed => json_failed

check for error

  • private pure function json_failed(json) result(failed)

    Author
    Jacob Williams
    Date
    12/5/2013

    Logical function to indicate if an exception has been thrown in a json_core.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(in) :: json

    Return Value logical(kind=LK)

    will be true if an exception has been thrown.

Get data from a json_value linked list.

Note

There are two versions (e.g. json_get_integer and json_get_integer_by_path). The first one gets the value from the json_value passed into the routine, while the second one gets the value from the json_value found by parsing the path. The path version is split up into unicode and non-unicode versions.

  • private subroutine json_get_by_path(json, me, path, p, found)

    Returns the json_value pointer given the path string.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), intent(in), pointer :: me

    a JSON linked list

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

    path to the variable

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

    pointer to the variable specified by path

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

    true if it was found

  • private subroutine wrap_json_get_by_path(json, me, path, p, found)

    Alternate version of json_get_by_path where “path” is kind=CDK.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), intent(in), pointer :: me
    character(kind=CDK, len=*), intent(in) :: path
    type(json_value), intent(out), pointer :: p
    logical(kind=LK), intent(out), optional :: found
  • private subroutine json_get_integer(json, me, value)

    Get an integer value from a json_value.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), intent(in), pointer :: me
    integer(kind=IK), intent(out) :: value

    the integer value

  • private subroutine json_get_integer_by_path(json, me, path, value, found, default)

    Get an integer value from a json_value, given the path string.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), intent(in), pointer :: me
    character(kind=CK, len=*), intent(in) :: path
    integer(kind=IK), intent(out) :: value
    logical(kind=LK), intent(out), optional :: found
    integer(kind=IK), intent(in), optional :: default

    default value if not found

  • private subroutine wrap_json_get_integer_by_path(json, me, path, value, found, default)

    Alternate version of json_get_integer_by_path, where “path” is kind=CDK.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), intent(in), pointer :: me
    character(kind=CDK, len=*), intent(in) :: path
    integer(kind=IK), intent(out) :: value
    logical(kind=LK), intent(out), optional :: found
    integer(kind=IK), intent(in), optional :: default

    default value if not found

  • private subroutine json_get_integer_vec(json, me, vec)

    Author
    Jacob Williams
    Date
    5/14/2014

    Get an integer vector from a json_value.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: me
    integer(kind=IK), intent(out), dimension(:), allocatable :: vec
  • private subroutine json_get_integer_vec_by_path(json, me, path, vec, found, default)

    Get an integer vector from a json_value, given the path string.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), intent(in), pointer :: me
    character(kind=CK, len=*), intent(in) :: path
    integer(kind=IK), intent(out), dimension(:), allocatable :: vec
    logical(kind=LK), intent(out), optional :: found
    integer(kind=IK), intent(in), optional, dimension(:) :: default

    default value if not found

  • private subroutine wrap_json_get_integer_vec_by_path(json, me, path, vec, found, default)

    Alternate version of json_get_integer_vec_by_path, where “path” is kind=CDK

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: me
    character(kind=CDK, len=*), intent(in) :: path
    integer(kind=IK), intent(out), dimension(:), allocatable :: vec
    logical(kind=LK), intent(out), optional :: found
    integer(kind=IK), intent(in), optional, dimension(:) :: default

    default value if not found

  • private subroutine json_get_real32(json, me, value)

    Alternate version of json_get_real where value=real32.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: me
    real(kind=real32), intent(out) :: value
  • private subroutine json_get_real32_by_path(json, me, path, value, found, default)

    Alternate version of json_get_real_by_path where value=real32.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: me
    character(kind=CK, len=*), intent(in) :: path
    real(kind=real32), intent(out) :: value
    logical(kind=LK), intent(out), optional :: found
    real(kind=real32), intent(in), optional :: default

    default value if not found

  • private subroutine wrap_json_get_real32_by_path(json, me, path, value, found, default)

    Alternate version of json_get_real32_by_path, where “path” is kind=CDK

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: me
    character(kind=CDK, len=*), intent(in) :: path
    real(kind=real32), intent(out) :: value
    logical(kind=LK), intent(out), optional :: found
    real(kind=real32), intent(in), optional :: default

    default value if not found

  • private subroutine json_get_real32_vec(json, me, vec)

    Alternate version of json_get_real_vec where vec is real32.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: me
    real(kind=real32), intent(out), dimension(:), allocatable :: vec
  • private subroutine json_get_real32_vec_by_path(json, me, path, vec, found, default)

    Alternate version of json_get_real_vec_by_path where vec is real32.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), intent(in), pointer :: me
    character(kind=CK, len=*), intent(in) :: path
    real(kind=real32), intent(out), dimension(:), allocatable :: vec
    logical(kind=LK), intent(out), optional :: found
    real(kind=real32), intent(in), optional, dimension(:) :: default

    default value if not found

  • private subroutine wrap_json_get_real32_vec_by_path(json, me, path, vec, found, default)

    Alternate version of json_get_real32_vec_by_path, where “path” is kind=CDK

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: me
    character(kind=CDK, len=*), intent(in) :: path
    real(kind=real32), intent(out), dimension(:), allocatable :: vec
    logical(kind=LK), intent(out), optional :: found
    real(kind=real32), intent(in), optional, dimension(:) :: default

    default value if not found

  • private subroutine json_get_real(json, me, value)

    Get a real value from a json_value.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: me
    real(kind=RK), intent(out) :: value
  • private subroutine json_get_real_by_path(json, me, path, value, found, default)

    Get a real value from a json_value, given the path.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: me
    character(kind=CK, len=*), intent(in) :: path
    real(kind=RK), intent(out) :: value
    logical(kind=LK), intent(out), optional :: found
    real(kind=RK), intent(in), optional :: default

    default value if not found

  • private subroutine wrap_json_get_real_by_path(json, me, path, value, found, default)

    Alternate version of json_get_real_by_path, where “path” is kind=CDK

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: me
    character(kind=CDK, len=*), intent(in) :: path
    real(kind=RK), intent(out) :: value
    logical(kind=LK), intent(out), optional :: found
    real(kind=RK), intent(in), optional :: default

    default value if not found

  • private subroutine json_get_real_vec(json, me, vec)

    Author
    Jacob Williams
    Date
    5/14/2014

    Get a real vector from a json_value.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: me
    real(kind=RK), intent(out), dimension(:), allocatable :: vec
  • private subroutine json_get_real_vec_by_path(json, me, path, vec, found, default)

    Get a real vector from a json_value, given the path.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), intent(in), pointer :: me
    character(kind=CK, len=*), intent(in) :: path
    real(kind=RK), intent(out), dimension(:), allocatable :: vec
    logical(kind=LK), intent(out), optional :: found
    real(kind=RK), intent(in), optional, dimension(:) :: default

    default value if not found

  • private subroutine wrap_json_get_real_vec_by_path(json, me, path, vec, found, default)

    Alternate version of json_get_real_vec_by_path, where “path” is kind=CDK

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: me
    character(kind=CDK, len=*), intent(in) :: path
    real(kind=RK), intent(out), dimension(:), allocatable :: vec
    logical(kind=LK), intent(out), optional :: found
    real(kind=RK), intent(in), optional, dimension(:) :: default

    default value if not found

  • private subroutine json_get_logical(json, me, value)

    Get a logical value from a json_value.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), intent(in), pointer :: me
    logical(kind=LK), intent(out) :: value
  • private subroutine json_get_logical_by_path(json, me, path, value, found, default)

    Get a logical value from a json_value, given the path.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), intent(in), pointer :: me
    character(kind=CK, len=*), intent(in) :: path
    logical(kind=LK), intent(out) :: value
    logical(kind=LK), intent(out), optional :: found
    logical(kind=LK), intent(in), optional :: default

    default value if not found

  • private subroutine wrap_json_get_logical_by_path(json, me, path, value, found, default)

    Alternate version of json_get_logical_by_path, where “path” is kind=CDK

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), intent(in), pointer :: me
    character(kind=CDK, len=*), intent(in) :: path
    logical(kind=LK), intent(out) :: value
    logical(kind=LK), intent(out), optional :: found
    logical(kind=LK), intent(in), optional :: default

    default value if not found

  • private subroutine json_get_logical_vec(json, me, vec)

    Author
    Jacob Williams
    Date
    5/14/2014

    Get a logical vector from json_value.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), intent(in), pointer :: me
    logical(kind=LK), intent(out), dimension(:), allocatable :: vec
  • private subroutine json_get_logical_vec_by_path(json, me, path, vec, found, default)

    Get a logical vector from a json_value, given the path.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), intent(in), pointer :: me
    character(kind=CK, len=*), intent(in) :: path
    logical(kind=LK), intent(out), dimension(:), allocatable :: vec
    logical(kind=LK), intent(out), optional :: found
    logical(kind=LK), intent(in), optional, dimension(:) :: default
  • private subroutine wrap_json_get_logical_vec_by_path(json, me, path, vec, found, default)

    Alternate version of json_get_logical_vec_by_path, where “path” is kind=CDK

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), intent(in), pointer :: me
    character(kind=CDK, len=*), intent(in) :: path
    logical(kind=LK), intent(out), dimension(:), allocatable :: vec
    logical(kind=LK), intent(out), optional :: found
    logical(kind=LK), intent(in), optional, dimension(:) :: default
  • private subroutine json_get_string(json, me, value)

    Get a character string from a json_value.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), intent(in), pointer :: me
    character(kind=CK, len=:), intent(out), allocatable :: value
  • private subroutine json_get_string_by_path(json, me, path, value, found, default)

    Get a character string from a json_value, given the path.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), intent(in), pointer :: me
    character(kind=CK, len=*), intent(in) :: path
    character(kind=CK, len=:), intent(out), allocatable :: value
    logical(kind=LK), intent(out), optional :: found
    character(kind=CK, len=*), intent(in), optional :: default
  • private subroutine wrap_json_get_string_by_path(json, me, path, value, found, default)

    Alternate version of json_get_string_by_path, where “path” is kind=CDK

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), intent(in), pointer :: me
    character(kind=CDK, len=*), intent(in) :: path
    character(kind=CK, len=:), intent(out), allocatable :: value
    logical(kind=LK), intent(out), optional :: found
    character(kind=CK, len=*), intent(in), optional :: default
  • private subroutine json_get_string_vec(json, me, vec)

    Author
    Jacob Williams
    Date
    5/14/2014

    Get a string vector from a json_value.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), intent(in), pointer :: me
    character(kind=CK, len=*), intent(out), dimension(:), allocatable :: vec
  • private subroutine json_get_string_vec_by_path(json, me, path, vec, found, default)

    Get a string vector from a json_value, given the path.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), intent(in), pointer :: me
    character(kind=CK, len=*), intent(in) :: path
    character(kind=CK, len=*), intent(out), dimension(:), allocatable :: vec
    logical(kind=LK), intent(out), optional :: found
    character(kind=CK, len=*), intent(in), optional, dimension(:) :: default
  • private subroutine wrap_json_get_string_vec_by_path(json, me, path, vec, found, default)

    Alternate version of json_get_string_vec_by_path, where “path” is kind=CDK

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), intent(in), pointer :: me
    character(kind=CDK, len=*), intent(in) :: path
    character(kind=CK, len=*), intent(out), dimension(:), allocatable :: vec
    logical(kind=LK), intent(out), optional :: found
    character(kind=CK, len=*), intent(in), optional, dimension(:) :: default
  • private subroutine json_get_alloc_string_vec(json, me, vec, ilen)

    Author
    Jacob Williams
    Date
    12/16/2016

    Get a string vector from a json_value. This is an alternate version of json_get_string_vec. This one returns an allocatable length character (where the string length is the maximum length of any element in the array). It also returns an integer array of the actual sizes of the strings in the JSON structure.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), intent(in), pointer :: me
    character(kind=CK, len=:), intent(out), dimension(:), allocatable :: vec
    integer(kind=IK), intent(out), dimension(:), allocatable :: ilen

    the actual length of each character string in the array

  • private subroutine json_get_alloc_string_vec_by_path(json, me, path, vec, ilen, found, default, default_ilen)

    Alternate version of json_get_alloc_string_vec where input is the path.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), intent(in), pointer :: me
    character(kind=CK, len=*), intent(in) :: path
    character(kind=CK, len=:), intent(out), dimension(:), allocatable :: vec
    integer(kind=IK), intent(out), dimension(:), allocatable :: ilen

    the actual length of each character string in the array

    logical(kind=LK), intent(out), optional :: found
    character(kind=CK, len=*), intent(in), optional, dimension(:) :: default
    integer(kind=IK), intent(in), optional, dimension(:) :: default_ilen

    the actual length of default

  • private subroutine wrap_json_get_alloc_string_vec_by_path(json, me, path, vec, ilen, found, default, default_ilen)

    Alternate version of json_get_alloc_string_vec_by_path, where “path” is kind=CDK

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), intent(in), pointer :: me
    character(kind=CDK, len=*), intent(in) :: path
    character(kind=CK, len=:), intent(out), dimension(:), allocatable :: vec
    integer(kind=IK), intent(out), dimension(:), allocatable :: ilen

    the actual length of each character string in the array

    logical(kind=LK), intent(out), optional :: found
    character(kind=CK, len=*), intent(in), optional, dimension(:) :: default
    integer(kind=IK), intent(in), optional, dimension(:) :: default_ilen

    the actual length of default

  • private recursive subroutine json_get_array(json, me, array_callback)

    This routine calls the user-supplied json_array_callback_func subroutine for each element in the array.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), intent(in), pointer :: me
    procedure(json_array_callback_func) :: array_callback
  • private recursive subroutine json_get_array_by_path(json, me, path, array_callback, found)

    This routine calls the user-supplied array_callback subroutine for each element in the array (specified by the path).

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), intent(in), pointer :: me
    character(kind=CK, len=*), intent(in) :: path
    procedure(json_array_callback_func) :: array_callback
    logical(kind=LK), intent(out), optional :: found
  • private recursive subroutine wrap_json_get_array_by_path(json, me, path, array_callback, found)

    Alternate version of json_get_array_by_path, where “path” is kind=CDK

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), intent(in), pointer :: me
    character(kind=CDK, len=*), intent(in) :: path
    procedure(json_array_callback_func) :: array_callback
    logical(kind=LK), intent(out), optional :: found

Return a child of a json_value structure.

  • private subroutine json_value_get_child_by_index(json, p, idx, child, found)

    Returns a child in the object or array given the index.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), intent(in), pointer :: p

    object or array JSON data

    integer(kind=IK), intent(in) :: idx

    index of the child (this is a 1-based Fortran style array index).

    type(json_value), pointer :: child

    pointer to the child

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

    true if the value was found (if not present, an exception will be thrown if it was not found. If present and not found, no exception will be thrown).

  • private subroutine json_value_get_child(json, p, child)

    Returns pointer to the first child of the object (or null() if it is not associated).

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), intent(in), pointer :: p

    object or array JSON data

    type(json_value), pointer :: child

    pointer to the child

  • private subroutine json_value_get_child_by_name(json, p, name, child, found)

    Returns a child in the object or array given the name string.

    Read more…

    Arguments

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

    the name of a child of p

    type(json_value), pointer :: child

    pointer to the child

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

    true if the value was found (if not present, an exception will be thrown if it was not found. If present and not found, no exception will be thrown).

  • private subroutine wrap_json_value_get_child_by_name(json, p, name, child, found)

    Alternate version of json_value_get_child_by_name where name is kind=CDK.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), intent(in), pointer :: p
    character(kind=CDK, len=*), intent(in) :: name
    type(json_value), pointer :: child
    logical(kind=LK), intent(out), optional :: found

procedure, private, nopass :: get_current_line_from_file_sequential

  • private subroutine get_current_line_from_file_sequential(iunit, line)

    Author
    Jacob Williams

    Rewind the file to the beginning of the current line, and return this line. The file is assumed to be opened. This is the SEQUENTIAL version (see also get_current_line_from_file_stream).

    Arguments

    Type IntentOptional Attributes Name
    integer(kind=IK), intent(in) :: iunit

    file unit number

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

    current line

procedure, private :: get_current_line_from_file_stream

  • private subroutine get_current_line_from_file_stream(json, iunit, line)

    Author
    Jacob Williams

    Rewind the file to the beginning of the current line, and return this line. The file is assumed to be opened. This is the STREAM version (see also get_current_line_from_file_sequential).

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    integer(kind=IK), intent(in) :: iunit

    file unit number

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

    current line

procedure, public :: get_next => json_get_next

get pointer to json_value next

  • private subroutine json_get_next(json, p, next)

    Author
    Jacob Williams
    Date
    10/31/2015

    Returns a pointer to the next of a json_value. If there is no next, then a null() pointer is returned.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), intent(in), pointer :: p

    JSON object

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

    pointer to next

procedure, public :: get_parent => json_get_parent

get pointer to json_value parent

  • private subroutine json_get_parent(json, p, parent)

    Author
    Jacob Williams
    Date
    10/16/2015

    Returns a pointer to the parent of a json_value. If there is no parent, then a null() pointer is returned.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), intent(in), pointer :: p

    JSON object

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

    pointer to parent

generic, public :: get_path => json_get_path, wrap_json_get_path

get the path to a JSON variable in a structure:

  • private subroutine json_get_path(json, p, path, found, use_alt_array_tokens, path_sep)

    Returns the path to a JSON object that is part of a linked list structure.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), intent(in), pointer :: p

    a JSON linked list object

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

    path to the variable

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

    true if there were no problems

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

    if true, then ‘()’ are used for array elements otherwise, ‘[]’ are used [default] (only used if path_mode=1)

    character(kind=CK, len=1), intent(in), optional :: path_sep

    character to use for path separator (otherwise use json%path_separator) (only used if path_mode=1)

  • private subroutine wrap_json_get_path(json, p, path, found, use_alt_array_tokens, path_sep)

    Wrapper for json_get_path where “path” and “path_sep” are kind=CDK.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), intent(in), pointer :: p

    a JSON linked list object

    character(kind=CDK, len=:), intent(out), allocatable :: path

    path to the variable

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

    true if there were no problems

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

    if true, then ‘()’ are used for array elements otherwise, ‘[]’ are used [default]

    character(kind=CDK, len=1), intent(in), optional :: path_sep

    character to use for path separator (default is ‘.’)

procedure, public :: get_previous => json_get_previous

get pointer to json_value previous

  • private subroutine json_get_previous(json, p, previous)

    Author
    Jacob Williams
    Date
    10/31/2015

    Returns a pointer to the previous of a json_value. If there is no previous, then a null() pointer is returned.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), intent(in), pointer :: p

    JSON object

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

    pointer to previous

procedure, public :: get_tail => json_get_tail

get pointer to json_value tail

  • private subroutine json_get_tail(json, p, tail)

    Author
    Jacob Williams
    Date
    10/31/2015

    Returns a pointer to the tail of a json_value (the last child of an array of object). If there is no tail, then a null() pointer is returned.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), intent(in), pointer :: p

    JSON object

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

    pointer to tail

generic, public :: info => json_info, json_info_by_path, wrap_json_info_by_path

get info about a json_value

  • private subroutine json_info(json, p, var_type, n_children, name)

    Author
    Jacob Williams
    Date
    2/13/2014

    Returns information about a json_value.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: p
    integer(kind=IK), intent(out), optional :: var_type

    variable type

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

    number of children

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

    variable name

  • private subroutine json_info_by_path(json, p, path, found, var_type, n_children, name)

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), intent(in), pointer :: p

    a JSON linked list

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

    path to the variable

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

    true if it was found

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

    variable type

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

    number of children

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

    variable name

  • private subroutine wrap_json_info_by_path(json, p, path, found, var_type, n_children, name)

    Alternate version of json_info_by_path where “path” is kind=CDK.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), intent(in), pointer :: p

    a JSON linked list

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

    path to the variable

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

    true if it was found

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

    variable type

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

    number of children

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

    variable name

procedure, public :: initialize => json_initialize

to initialize some parsing parameters

  • private subroutine json_initialize(me, verbose, compact_reals, print_signs, real_format, spaces_per_tab, strict_type_checking, trailing_spaces_significant, case_sensitive_keys, no_whitespace, unescape_strings, comment_char, path_mode, path_separator, compress_vectors, allow_duplicate_keys, escape_solidus, stop_on_error, null_to_real_mode, non_normal_mode, use_quiet_nan, strict_integer_type_checking, allow_trailing_comma)

    Author
    Jacob Williams
    Date
    12/4/2013

    Initialize the json_core instance.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), 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. (default is false)

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

    for name and path comparisons, are they case sensitive. (default is true)

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

    if true, printing the JSON structure is done without adding any non-significant spaces or linebreaks (default is false)

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

    If false, then the raw escaped string is returned from json_get_string and similar routines. If true [default], then the string is returned unescaped.

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

    If present, these characters are used to denote comments in the JSON file, which will be ignored if present. Example: !, #, or /!#. Setting this to a blank string disables the ignoring of comments. (Default is /!#).

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

    How the path strings are interpreted in the get_by_path routines:

    Read more…
    character(kind=CK, len=1), intent(in), optional :: path_separator

    The path separator to use in the “default” mode for the paths in the various get_by_path routines. Example: . [default] or %. Note: if path_mode/=1 then this is ignored.

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

    If true, then arrays of integers, nulls, doubles, and logicals are printed all on one line. [Note: no_whitespace will override this option if necessary]. (Default is False).

    logical(kind=LK), intent(in), optional :: allow_duplicate_keys Read more…
    logical(kind=LK), intent(in), optional :: escape_solidus

    Note that this option does not affect parsing (both escaped and unescaped are still valid in all cases).

    Read more…
    logical(kind=LK), intent(in), optional :: stop_on_error

    If an exception is raised, then immediately quit. (Default is False).

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

    if strict_type_checking=false:

    Read more…
    integer(kind=IK), intent(in), optional :: non_normal_mode

    How to serialize NaN, Infinity, and -Infinity real values:

    Read more…
    logical(kind=LK), intent(in), optional :: use_quiet_nan Read more…
    logical(kind=LK), intent(in), optional :: strict_integer_type_checking

    (default is true)

    Read more…
    logical(kind=LK), intent(in), optional :: allow_trailing_comma

    Allow a single trailing comma in arrays and objects. (default is true)

insert a new element after an existing one, updating the JSON structure accordingly

  • private subroutine json_value_insert_after(json, p, element)

    Inserts element after p, and updates the JSON structure accordingly.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: p

    a value from a JSON structure (presumably, this is a child of an object or array).

    type(json_value), pointer :: element

    the element to insert after p

  • private subroutine json_value_insert_after_child_by_index(json, p, idx, element)

    Inserts element after the idx-th child of p, and updates the JSON structure accordingly. This is just a wrapper for json_value_insert_after.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: p

    a JSON object or array.

    integer(kind=IK), intent(in) :: idx

    the index of the child of p to insert the new element after (this is a 1-based Fortran style array index)

    type(json_value), pointer :: element

    the element to insert

procedure, public :: is_child_of => json_value_is_child_of

Check if a json_value is a descendant of another.

  • private function json_value_is_child_of(json, p1, p2) result(is_child_of)

    Author
    Jacob Williams
    Date
    4/28/2016

    Returns True if p2 is a descendant of p1 (i.e, a child, or a child of child, etc.)

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: p1
    type(json_value), pointer :: p2

    Return Value logical(kind=LK)

procedure, private :: is_vector => json_is_vector

  • private function json_is_vector(json, p) result(is_vector)

    Returns true if all the children are the same type (and a scalar). Note that integers and reals are considered the same type for this purpose. This routine is used for the compress_vectors option.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: p

    Return Value logical(kind=LK)

    if all elements of a vector are scalars of the same type

procedure, private :: json_add_integer_by_path

  • private subroutine json_add_integer_by_path(json, me, path, value, found, was_created)

    Add an integer value to a json_value, given the path.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: me

    the JSON structure

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

    the path to the variable

    integer(kind=IK), intent(in) :: value

    the value to add

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

    if the variable was found

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

    if the variable had to be created

procedure, private :: json_add_integer_vec_by_path

  • private subroutine json_add_integer_vec_by_path(json, me, path, value, found, was_created)

    Wrapper to json_add_integer_by_path for adding an integer vector by path.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: me

    the JSON structure

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

    the path to the variable

    integer(kind=IK), intent(in), dimension(:) :: value

    the vector to add

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

    if the variable was found

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

    if the variable had to be created

procedure, private :: json_add_logical_by_path

  • private subroutine json_add_logical_by_path(json, me, path, value, found, was_created)

    Add a logical value to a json_value, given the path.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: me

    the JSON structure

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

    the path to the variable

    logical(kind=LK), intent(in) :: value

    the value to add

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

    if the variable was found

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

    if the variable had to be created

procedure, private :: json_add_logical_vec_by_path

  • private subroutine json_add_logical_vec_by_path(json, me, path, value, found, was_created)

    Wrapper to json_add_logical_by_path for adding a logical vector by path.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: me

    the JSON structure

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

    the path to the variable

    logical(kind=LK), intent(in), dimension(:) :: value

    the vector to add

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

    if the variable was found

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

    if the variable had to be created

procedure, private :: json_add_member_by_path

  • private subroutine json_add_member_by_path(json, me, path, p, found, was_created)

    Add a new member (json_value pointer) to a JSON structure, given the path.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: me

    the JSON structure

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

    the path to the variable

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

    the value to add

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

    if the variable was found

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

    if the variable had to be created

procedure, private :: json_add_real32_by_path

  • private subroutine json_add_real32_by_path(json, me, path, value, found, was_created)

    Alternate version of json_add_real_by_path where value=real32.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: me

    the JSON structure

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

    the path to the variable

    real(kind=real32), intent(in) :: value

    the value to add

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

    if the variable was found

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

    if the variable had to be created

procedure, private :: json_add_real32_vec_by_path

  • private subroutine json_add_real32_vec_by_path(json, me, path, value, found, was_created)

    Wrapper to json_add_real_by_path for adding a real vector by path.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: me

    the JSON structure

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

    the path to the variable

    real(kind=real32), intent(in), dimension(:) :: value

    the vector to add

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

    if the variable was found

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

    if the variable had to be created

procedure, private :: json_add_real_by_path

  • private subroutine json_add_real_by_path(json, me, path, value, found, was_created)

    Add an real value to a json_value, given the path.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: me

    the JSON structure

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

    the path to the variable

    real(kind=RK), intent(in) :: value

    the value to add

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

    if the variable was found

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

    if the variable had to be created

procedure, private :: json_add_real_vec_by_path

  • private subroutine json_add_real_vec_by_path(json, me, path, value, found, was_created)

    Wrapper to json_add_real_by_path for adding a real vector by path.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: me

    the JSON structure

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

    the path to the variable

    real(kind=RK), intent(in), dimension(:) :: value

    the vector to add

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

    if the variable was found

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

    if the variable had to be created

procedure, private :: json_add_string_by_path

  • private subroutine json_add_string_by_path(json, me, path, value, found, was_created, trim_str, adjustl_str)

    Add a string value to a json_value, given the path.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: me

    the JSON structure

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

    the path to the variable

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

    the value to add

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

    if the variable was found

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

    if the variable had to be created

    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

procedure, private :: json_add_string_by_path_path_ascii

  • private subroutine json_add_string_by_path_path_ascii(json, me, path, value, found, was_created, trim_str, adjustl_str)

    Wrapper for json_add_string_by_path where “path” is kind=CDK.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: me

    the JSON structure

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

    the path to the variable

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

    the value to add

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

    if the variable was found

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

    if the variable had to be created

    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

procedure, private :: json_add_string_by_path_value_ascii

  • private subroutine json_add_string_by_path_value_ascii(json, me, path, value, found, was_created, trim_str, adjustl_str)

    Wrapper for json_add_string_by_path where “value” is kind=CDK.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: me

    the JSON structure

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

    the path to the variable

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

    the value to add

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

    if the variable was found

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

    if the variable had to be created

    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

procedure, private :: json_add_string_vec_by_path

  • private subroutine json_add_string_vec_by_path(json, me, path, value, found, was_created, ilen, trim_str, adjustl_str)

    Wrapper to json_add_string_by_path for adding a string vector by path.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: me

    the JSON structure

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

    the path to the variable

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

    the vector to add

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

    if the variable was found

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

    if the variable had to be created

    integer(kind=IK), intent(in), optional, dimension(:) :: ilen

    the string lengths of each element in value. If not present, the full len(value) string is added for each element.

    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

procedure, private :: json_add_string_vec_by_path_path_ascii

  • private subroutine json_add_string_vec_by_path_path_ascii(json, me, path, value, found, was_created, ilen, trim_str, adjustl_str)

    Wrapper for json_add_string_vec_by_path where “path” is kind=CDK).

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: me

    the JSON structure

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

    the path to the variable

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

    the vector to add

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

    if the variable was found

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

    if the variable had to be created

    integer(kind=IK), intent(in), optional, dimension(:) :: ilen

    the string lengths of each element in value. If not present, the full len(value) string is added for each element.

    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

procedure, private :: json_add_string_vec_by_path_value_ascii

  • private subroutine json_add_string_vec_by_path_value_ascii(json, me, path, value, found, was_created, ilen, trim_str, adjustl_str)

    Wrapper for json_add_string_vec_by_path where “value” is kind=CDK).

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: me

    the JSON structure

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

    the path to the variable

    character(kind=CDK, len=*), intent(in), dimension(:) :: value

    the vector to add

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

    if the variable was found

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

    if the variable had to be created

    integer(kind=IK), intent(in), optional, dimension(:) :: ilen

    the string lengths of each element in value. If not present, the full len(value) string is added for each element.

    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

procedure, private :: json_create_by_path

  • private subroutine json_create_by_path(json, me, path, p, found, was_created)

    Returns the json_value pointer given the path string, If necessary, by creating the variables as needed.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), intent(in), pointer :: me

    a JSON linked list

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

    path to the variable

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

    pointer to the variable specify by path

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

    true if there were no errors (variable found or created)

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

    true if it was actually created (as opposed to already being there)

procedure, private :: json_get_alloc_string_vec

  • private subroutine json_get_alloc_string_vec(json, me, vec, ilen)

    Author
    Jacob Williams
    Date
    12/16/2016

    Get a string vector from a json_value. This is an alternate version of json_get_string_vec. This one returns an allocatable length character (where the string length is the maximum length of any element in the array). It also returns an integer array of the actual sizes of the strings in the JSON structure.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), intent(in), pointer :: me
    character(kind=CK, len=:), intent(out), dimension(:), allocatable :: vec
    integer(kind=IK), intent(out), dimension(:), allocatable :: ilen

    the actual length of each character string in the array

procedure, private :: json_get_alloc_string_vec_by_path

  • private subroutine json_get_alloc_string_vec_by_path(json, me, path, vec, ilen, found, default, default_ilen)

    Alternate version of json_get_alloc_string_vec where input is the path.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), intent(in), pointer :: me
    character(kind=CK, len=*), intent(in) :: path
    character(kind=CK, len=:), intent(out), dimension(:), allocatable :: vec
    integer(kind=IK), intent(out), dimension(:), allocatable :: ilen

    the actual length of each character string in the array

    logical(kind=LK), intent(out), optional :: found
    character(kind=CK, len=*), intent(in), optional, dimension(:) :: default
    integer(kind=IK), intent(in), optional, dimension(:) :: default_ilen

    the actual length of default

procedure, private :: json_get_array

procedure, private :: json_get_array_by_path

  • private recursive subroutine json_get_array_by_path(json, me, path, array_callback, found)

    This routine calls the user-supplied array_callback subroutine for each element in the array (specified by the path).

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), intent(in), pointer :: me
    character(kind=CK, len=*), intent(in) :: path
    procedure(json_array_callback_func) :: array_callback
    logical(kind=LK), intent(out), optional :: found

procedure, private :: json_get_by_path

  • private subroutine json_get_by_path(json, me, path, p, found)

    Returns the json_value pointer given the path string.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), intent(in), pointer :: me

    a JSON linked list

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

    path to the variable

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

    pointer to the variable specified by path

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

    true if it was found

procedure, private :: json_get_by_path_default

  • private subroutine json_get_by_path_default(json, me, path, p, found, create_it, was_created)

    Returns the json_value pointer given the path string.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), intent(in), pointer :: me

    a JSON linked list

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

    path to the variable

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

    pointer to the variable specify by path

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

    true if it was found

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

    if a variable is not present in the path, then it is created. the leaf node is returned as a null json type and can be changed by the caller.

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

    if create_it is true, this will be true if the variable was actually created. Otherwise it will be false.

procedure, private :: json_get_by_path_jsonpath_bracket

  • private subroutine json_get_by_path_jsonpath_bracket(json, me, path, p, found, create_it, was_created)

    Author
    Jacob Williams
    Date
    9/2/2017

    Returns the json_value pointer given the path string, using the “JSON Pointer” path specification defined by the JSONPath “bracket-notation”.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), intent(in), pointer :: me

    a JSON linked list

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

    path to the variable (using JSONPath “bracket-notation”)

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

    pointer to the variable specify by path

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

    true if it was found

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

    if a variable is not present in the path, then it is created. the leaf node is returned as a null json type and can be changed by the caller.

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

    if create_it is true, this will be true if the variable was actually created. Otherwise it will be false.

procedure, private :: json_get_by_path_rfc6901

  • private subroutine json_get_by_path_rfc6901(json, me, path, p, found)

    Author
    Jacob Williams
    Date
    2/4/2017

    Returns the json_value pointer given the path string, using the “JSON Pointer” path specification defined by RFC 6901.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), intent(in), pointer :: me

    a JSON linked list

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

    path to the variable (an RFC 6901 “JSON Pointer”)

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

    pointer to the variable specify by path

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

    true if it was found

procedure, private :: json_get_integer

  • private subroutine json_get_integer(json, me, value)

    Get an integer value from a json_value.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), intent(in), pointer :: me
    integer(kind=IK), intent(out) :: value

    the integer value

procedure, private :: json_get_integer_by_path

  • private subroutine json_get_integer_by_path(json, me, path, value, found, default)

    Get an integer value from a json_value, given the path string.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), intent(in), pointer :: me
    character(kind=CK, len=*), intent(in) :: path
    integer(kind=IK), intent(out) :: value
    logical(kind=LK), intent(out), optional :: found
    integer(kind=IK), intent(in), optional :: default

    default value if not found

procedure, private :: json_get_integer_vec

  • private subroutine json_get_integer_vec(json, me, vec)

    Author
    Jacob Williams
    Date
    5/14/2014

    Get an integer vector from a json_value.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: me
    integer(kind=IK), intent(out), dimension(:), allocatable :: vec

procedure, private :: json_get_integer_vec_by_path

  • private subroutine json_get_integer_vec_by_path(json, me, path, vec, found, default)

    Get an integer vector from a json_value, given the path string.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), intent(in), pointer :: me
    character(kind=CK, len=*), intent(in) :: path
    integer(kind=IK), intent(out), dimension(:), allocatable :: vec
    logical(kind=LK), intent(out), optional :: found
    integer(kind=IK), intent(in), optional, dimension(:) :: default

    default value if not found

procedure, private :: json_get_logical

procedure, private :: json_get_logical_by_path

  • private subroutine json_get_logical_by_path(json, me, path, value, found, default)

    Get a logical value from a json_value, given the path.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), intent(in), pointer :: me
    character(kind=CK, len=*), intent(in) :: path
    logical(kind=LK), intent(out) :: value
    logical(kind=LK), intent(out), optional :: found
    logical(kind=LK), intent(in), optional :: default

    default value if not found

procedure, private :: json_get_logical_vec

  • private subroutine json_get_logical_vec(json, me, vec)

    Author
    Jacob Williams
    Date
    5/14/2014

    Get a logical vector from json_value.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), intent(in), pointer :: me
    logical(kind=LK), intent(out), dimension(:), allocatable :: vec

procedure, private :: json_get_logical_vec_by_path

  • private subroutine json_get_logical_vec_by_path(json, me, path, vec, found, default)

    Get a logical vector from a json_value, given the path.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), intent(in), pointer :: me
    character(kind=CK, len=*), intent(in) :: path
    logical(kind=LK), intent(out), dimension(:), allocatable :: vec
    logical(kind=LK), intent(out), optional :: found
    logical(kind=LK), intent(in), optional, dimension(:) :: default

procedure, private :: json_get_path

  • private subroutine json_get_path(json, p, path, found, use_alt_array_tokens, path_sep)

    Returns the path to a JSON object that is part of a linked list structure.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), intent(in), pointer :: p

    a JSON linked list object

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

    path to the variable

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

    true if there were no problems

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

    if true, then ‘()’ are used for array elements otherwise, ‘[]’ are used [default] (only used if path_mode=1)

    character(kind=CK, len=1), intent(in), optional :: path_sep

    character to use for path separator (otherwise use json%path_separator) (only used if path_mode=1)

procedure, private :: json_get_real

  • private subroutine json_get_real(json, me, value)

    Get a real value from a json_value.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: me
    real(kind=RK), intent(out) :: value

procedure, private :: json_get_real32

  • private subroutine json_get_real32(json, me, value)

    Alternate version of json_get_real where value=real32.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: me
    real(kind=real32), intent(out) :: value

procedure, private :: json_get_real32_by_path

  • private subroutine json_get_real32_by_path(json, me, path, value, found, default)

    Alternate version of json_get_real_by_path where value=real32.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: me
    character(kind=CK, len=*), intent(in) :: path
    real(kind=real32), intent(out) :: value
    logical(kind=LK), intent(out), optional :: found
    real(kind=real32), intent(in), optional :: default

    default value if not found

procedure, private :: json_get_real32_vec

  • private subroutine json_get_real32_vec(json, me, vec)

    Alternate version of json_get_real_vec where vec is real32.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: me
    real(kind=real32), intent(out), dimension(:), allocatable :: vec

procedure, private :: json_get_real32_vec_by_path

  • private subroutine json_get_real32_vec_by_path(json, me, path, vec, found, default)

    Alternate version of json_get_real_vec_by_path where vec is real32.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), intent(in), pointer :: me
    character(kind=CK, len=*), intent(in) :: path
    real(kind=real32), intent(out), dimension(:), allocatable :: vec
    logical(kind=LK), intent(out), optional :: found
    real(kind=real32), intent(in), optional, dimension(:) :: default

    default value if not found

procedure, private :: json_get_real_by_path

  • private subroutine json_get_real_by_path(json, me, path, value, found, default)

    Get a real value from a json_value, given the path.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: me
    character(kind=CK, len=*), intent(in) :: path
    real(kind=RK), intent(out) :: value
    logical(kind=LK), intent(out), optional :: found
    real(kind=RK), intent(in), optional :: default

    default value if not found

procedure, private :: json_get_real_vec

  • private subroutine json_get_real_vec(json, me, vec)

    Author
    Jacob Williams
    Date
    5/14/2014

    Get a real vector from a json_value.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: me
    real(kind=RK), intent(out), dimension(:), allocatable :: vec

procedure, private :: json_get_real_vec_by_path

  • private subroutine json_get_real_vec_by_path(json, me, path, vec, found, default)

    Get a real vector from a json_value, given the path.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), intent(in), pointer :: me
    character(kind=CK, len=*), intent(in) :: path
    real(kind=RK), intent(out), dimension(:), allocatable :: vec
    logical(kind=LK), intent(out), optional :: found
    real(kind=RK), intent(in), optional, dimension(:) :: default

    default value if not found

procedure, private :: json_get_string

  • private subroutine json_get_string(json, me, value)

    Get a character string from a json_value.

    Arguments

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

procedure, private :: json_get_string_by_path

  • private subroutine json_get_string_by_path(json, me, path, value, found, default)

    Get a character string from a json_value, given the path.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), intent(in), pointer :: me
    character(kind=CK, len=*), intent(in) :: path
    character(kind=CK, len=:), intent(out), allocatable :: value
    logical(kind=LK), intent(out), optional :: found
    character(kind=CK, len=*), intent(in), optional :: default

procedure, private :: json_get_string_vec

  • private subroutine json_get_string_vec(json, me, vec)

    Author
    Jacob Williams
    Date
    5/14/2014

    Get a string vector from a json_value.

    Arguments

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

procedure, private :: json_get_string_vec_by_path

  • private subroutine json_get_string_vec_by_path(json, me, path, vec, found, default)

    Get a string vector from a json_value, given the path.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), intent(in), pointer :: me
    character(kind=CK, len=*), intent(in) :: path
    character(kind=CK, len=*), intent(out), dimension(:), allocatable :: vec
    logical(kind=LK), intent(out), optional :: found
    character(kind=CK, len=*), intent(in), optional, dimension(:) :: default

procedure, private :: json_info

  • private subroutine json_info(json, p, var_type, n_children, name)

    Author
    Jacob Williams
    Date
    2/13/2014

    Returns information about a json_value.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: p
    integer(kind=IK), intent(out), optional :: var_type

    variable type

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

    number of children

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

    variable name

procedure, private :: json_info_by_path

  • private subroutine json_info_by_path(json, p, path, found, var_type, n_children, name)

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), intent(in), pointer :: p

    a JSON linked list

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

    path to the variable

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

    true if it was found

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

    variable type

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

    number of children

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

    variable name

procedure, private :: json_matrix_info

  • private subroutine json_matrix_info(json, p, is_matrix, var_type, n_sets, set_size, name)

    Author
    Jacob Williams
    Date
    10/16/2015

    Alternate version of json_info that returns matrix information about a json_value.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: p

    a JSON linked list

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

    true if it is a valid matrix

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

    variable type of data in the matrix (if all elements have the same type)

    integer(kind=IK), intent(out), optional :: n_sets

    number of data sets (i.e., matrix rows if using row-major order)

    integer(kind=IK), intent(out), optional :: set_size

    size of each data set (i.e., matrix cols if using row-major order)

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

    variable name

procedure, private :: json_matrix_info_by_path

  • private subroutine json_matrix_info_by_path(json, p, path, is_matrix, found, var_type, n_sets, set_size, name)

    Returns matrix information about a json_value, given the path.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: p

    a JSON linked list

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

    path to the variable

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

    true if it is a valid matrix

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

    true if it was found

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

    variable type of data in the matrix (if all elements have the same type)

    integer(kind=IK), intent(out), optional :: n_sets

    number of data sets (i.e., matrix rows if using row-major order)

    integer(kind=IK), intent(out), optional :: set_size

    size of each data set (i.e., matrix cols if using row-major order)

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

    variable name

procedure, private :: json_parse_file

  • private subroutine json_parse_file(json, file, p, unit)

    Parse the JSON file and populate the json_value tree.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    character(kind=CDK, len=*), intent(in) :: file

    JSON file name

    type(json_value), pointer :: p

    output structure

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

    file unit number (/= 0)

procedure, private :: json_parse_string

  • private subroutine json_parse_string(json, p, str)

    Parse the JSON string and populate the json_value tree.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: p

    output structure

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

    string with JSON data

procedure, private :: json_print_to_console

procedure, private :: json_print_to_filename

  • private subroutine json_print_to_filename(json, p, filename)

    Author
    Jacob Williams
    Date
    12/23/2014

    Print the json_value structure to a file.

    Arguments

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

    the filename to print to (should not already be open)

procedure, private :: json_print_to_unit

  • private subroutine json_print_to_unit(json, p, iunit)

    Author
    Jacob Williams
    Date
    6/20/2014

    Print the json_value structure to a file.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), intent(in), pointer :: p
    integer(kind=IK), intent(in) :: iunit

    the file unit (the file must already have been opened, can’t be -1).

procedure, private :: json_rename_by_path

  • private subroutine json_rename_by_path(json, me, path, name, found)

    Rename a json_value, given the path.

    Read more…

    Arguments

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

    path to the variable to rename

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

    the new name

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

    if there were no errors

procedure, private :: json_rename_by_path_name_ascii

  • private subroutine json_rename_by_path_name_ascii(json, me, path, name, found)

    Alternate version of json_rename_by_path, where “name” is kind=CDK

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), intent(in), pointer :: me
    character(kind=CK, len=*), intent(in) :: path
    character(kind=CDK, len=*), intent(in) :: name
    logical(kind=LK), intent(out), optional :: found

procedure, private :: json_rename_by_path_path_ascii

  • private subroutine json_rename_by_path_path_ascii(json, me, path, name, found)

    Alternate version of json_rename_by_path, where “path” is kind=CDK

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), intent(in), pointer :: me
    character(kind=CDK, len=*), intent(in) :: path
    character(kind=CK, len=*), intent(in) :: name
    logical(kind=LK), intent(out), optional :: found

procedure, private :: json_string_info

  • private subroutine json_string_info(json, p, ilen, max_str_len, found)

    Author
    Jacob Williams
    Date
    12/18/2016

    Returns information about character strings returned from a json_value.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: p
    integer(kind=IK), intent(out), optional, dimension(:), allocatable :: ilen

    if p is an array, this is the actual length of each character string in the array. if not an array, this is returned unallocated.

    integer(kind=IK), intent(out), optional :: max_str_len

    The maximum length required to hold the string representation returned by a call to a get routine. If a scalar, this is just the length of the scalar. If a vector, this is the maximum length of any element.

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

    true if there were no errors. if not present, an error will throw an exception

procedure, private :: json_throw_exception

  • private subroutine json_throw_exception(json, msg, found)

    Author
    Jacob Williams
    Date
    12/4/2013

    Throw an exception in the json_core. This routine sets the error flag, and prevents any subsequent routine from doing anything, until json_clear_exceptions is called.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    character(kind=CK, len=*), intent(in) :: msg

    the error message

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

    if the caller is handling the exception with an optimal return argument. If so, json%stop_on_error is ignored.

procedure, private :: json_update_integer

  • private subroutine json_update_integer(json, p, path, val, found)

    Author
    Jacob Williams
    Date
    12/6/2014

    Given the path string, if the variable is present, and is a scalar, then update its value. If it is not present, then create it and set its value.

    Read more…

    Arguments

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

    path to the variable in the structure

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

    the new value

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

    if the variable was found and was a scalar.

procedure, private :: json_update_logical

  • private subroutine json_update_logical(json, p, path, val, found)

    Author
    Jacob Williams
    Date
    12/6/2014

    Given the path string, if the variable is present, and is a scalar, then update its value. If it is not present, then create it and set its value.

    Read more…

    Arguments

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

    path to the variable in the structure

    logical(kind=LK), intent(in) :: val

    the new value

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

    if the variable was found and was a scalar.

procedure, private :: json_update_real

  • private subroutine json_update_real(json, p, path, val, found)

    Author
    Jacob Williams
    Date
    12/6/2014

    Given the path string, if the variable is present, and is a scalar, then update its value. If it is not present, then create it and set its value.

    Read more…

    Arguments

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

    path to the variable in the structure

    real(kind=RK), intent(in) :: val

    the new value

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

    if the variable was found and was a scalar.

procedure, private :: json_update_real32

  • private subroutine json_update_real32(json, p, path, val, found)

    Alternate version of json_update_real, where val is real32.

    Arguments

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

    path to the variable in the structure

    real(kind=real32), intent(in) :: val

    the new value

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

    if the variable was found and was a scalar.

procedure, private :: json_update_string

  • private subroutine json_update_string(json, p, path, val, found, trim_str, adjustl_str)

    Author
    Jacob Williams
    Date
    12/6/2014

    Given the path string, if the variable is present, and is a scalar, then update its value. If it is not present, then create it and set its value.

    Read more…

    Arguments

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

    path to the variable in the structure

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

    the new value

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

    if the variable was found and was a scalar.

    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)

procedure, private :: json_update_string_name_ascii

  • private subroutine json_update_string_name_ascii(json, p, path, val, found, trim_str, adjustl_str)

    Alternate version of json_update_string, where path is kind=CDK.

    Arguments

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

    path to the variable in the structure

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

    the new value

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

    if the variable was found and was a scalar.

    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)

procedure, private :: json_update_string_val_ascii

  • private subroutine json_update_string_val_ascii(json, p, path, val, found, trim_str, adjustl_str)

    Alternate version of json_update_string, where val is kind=CDK.

    Arguments

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

    path to the variable in the structure

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

    the new value

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

    if the variable was found and was a scalar.

    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)

procedure, private :: json_valid_path

  • private function json_valid_path(json, p, path) result(found)

    Returns true if the path is present in the p JSON structure.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), intent(in), pointer :: p

    a JSON linked list

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

    path to the variable

    Return Value logical(kind=LK)

    true if it was found

procedure, private :: json_value_add_integer

  • private subroutine json_value_add_integer(json, p, name, val)

    Author
    Jacob Williams
    Date
    1/20/2014

    Add an integer value child to the json_value variable.

    Read more…

    Arguments

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

procedure, private :: json_value_add_integer_vec

  • private subroutine json_value_add_integer_vec(json, p, name, val)

    Author
    Jacob Williams
    Date
    1/20/2014

    Add a integer vector child to the json_value variable.

    Read more…

    Arguments

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

    name of the variable

    integer(kind=IK), intent(in), dimension(:) :: val

    value

procedure, private :: json_value_add_logical

  • private subroutine json_value_add_logical(json, p, name, val)

    Author
    Jacob Williams
    Date
    1/20/2014

    Add a logical value child to the json_value variable.

    Read more…

    Arguments

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

    name of the variable

    logical(kind=LK), intent(in) :: val

    value

procedure, private :: json_value_add_logical_vec

  • private subroutine json_value_add_logical_vec(json, p, name, val)

    Author
    Jacob Williams
    Date
    1/20/2014

    Add a logical vector child to the json_value variable.

    Read more…

    Arguments

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

    name of the vector

    logical(kind=LK), intent(in), dimension(:) :: val

    value

procedure, private :: json_value_add_member

  • private subroutine json_value_add_member(json, p, member)

    Adds member as a child of p.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: p

    p must be a json_object or a json_array

    type(json_value), pointer :: member

    the child member to add to p

procedure, private :: json_value_add_null

procedure, private :: json_value_add_real

  • private subroutine json_value_add_real(json, p, name, val)

    Author
    Jacob Williams
    Date
    1/19/2014

    Add a real value child to the json_value variable.

    Read more…

    Arguments

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

    variable name

    real(kind=RK), intent(in) :: val

    real value

procedure, private :: json_value_add_real32

  • private subroutine json_value_add_real32(json, p, name, val)

    Alternate version of json_value_add_real where val is real32.

    Arguments

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

    variable name

    real(kind=real32), intent(in) :: val

    real value

procedure, private :: json_value_add_real32_vec

  • private subroutine json_value_add_real32_vec(json, p, name, val)

    Alternate version of json_value_add_real_vec where val is real32.

    Arguments

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

procedure, private :: json_value_add_real_vec

  • private subroutine json_value_add_real_vec(json, p, name, val)

    Author
    Jacob Williams
    Date
    1/20/2014

    Add a real vector child to the json_value variable.

    Read more…

    Arguments

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

procedure, private :: json_value_add_string

  • private subroutine json_value_add_string(json, p, name, val, trim_str, adjustl_str)

    Author
    Jacob Williams
    Date
    1/19/2014

    Add a character string child to the json_value variable.

    Read more…

    Arguments

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

    name of the variable

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

    value

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

    if TRIM() should be called for the val

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

    if ADJUSTL() should be called for the val

procedure, private :: json_value_add_string_name_ascii

  • private subroutine json_value_add_string_name_ascii(json, p, name, val, trim_str, adjustl_str)

    Alternate version of json_value_add_string where name is kind=CDK.

    Arguments

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

    name of the variable

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

    value

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

    if TRIM() should be called for the val

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

    if ADJUSTL() should be called for the val

procedure, private :: json_value_add_string_val_ascii

  • private subroutine json_value_add_string_val_ascii(json, p, name, val, trim_str, adjustl_str)

    Alternate version of json_value_add_string where val is kind=CDK.

    Arguments

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

    name of the variable

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

    value

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

    if TRIM() should be called for the val

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

    if ADJUSTL() should be called for the val

procedure, private :: json_value_add_string_vec

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

    Author
    Jacob Williams
    Date
    1/19/2014

    Add a character string vector child to the json_value variable.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    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

procedure, private :: json_value_add_string_vec_name_ascii

  • private subroutine json_value_add_string_vec_name_ascii(json, p, name, val, trim_str, adjustl_str)

    Alternate version of json_value_add_string_vec where name is kind=CDK.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: p
    character(kind=CDK, len=*), intent(in) :: name
    character(kind=CK, len=*), intent(in), dimension(:) :: val
    logical(kind=LK), intent(in), optional :: trim_str
    logical(kind=LK), intent(in), optional :: adjustl_str

procedure, private :: json_value_add_string_vec_val_ascii

  • private subroutine json_value_add_string_vec_val_ascii(json, p, name, val, trim_str, adjustl_str)

    Alternate version of json_value_add_string_vec where val is kind=CDK.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: p
    character(kind=CK, len=*), intent(in) :: name
    character(kind=CDK, len=*), intent(in), dimension(:) :: val
    logical(kind=LK), intent(in), optional :: trim_str
    logical(kind=LK), intent(in), optional :: adjustl_str

procedure, private, nopass :: json_value_clone_func

  • private recursive subroutine json_value_clone_func(from, to, parent, previous, tail)

    Author
    Jacob Williams
    Date
    10/31/2015

    Recursive deep copy function called by json_clone.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    type(json_value), pointer :: from

    this is the structure to clone

    type(json_value), pointer :: to

    the clone is put here (it must not already be associated)

    type(json_value), optional, pointer :: parent

    to%parent

    type(json_value), optional, pointer :: previous

    to%previous

    logical, optional :: tail

    if “to” is the tail of its parent’s children

procedure, private :: json_value_create_array

  • private subroutine json_value_create_array(json, p, name)

    Author
    Jacob Williams

    Allocate a json_value pointer and make it an array variable. The pointer should not already be allocated.

    Read more…

    Arguments

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

procedure, private :: json_value_create_integer

  • private subroutine json_value_create_integer(json, p, val, name)

    Author
    Jacob Williams

    Allocate a json_value pointer and make it an integer(IK) variable. The pointer should not already be allocated.

    Read more…

    Arguments

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

procedure, private :: json_value_create_logical

  • private subroutine json_value_create_logical(json, p, val, name)

    Author
    Jacob Williams

    Allocate a json_value pointer and make it a logical(LK) variable. The pointer should not already be allocated.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: p
    logical(kind=LK), intent(in) :: val

    variable value

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

    variable name

procedure, private :: json_value_create_null

  • private subroutine json_value_create_null(json, p, name)

    Author
    Jacob Williams

    Allocate a json_value pointer and make it a null variable. The pointer should not already be allocated.

    Read more…

    Arguments

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

procedure, private :: json_value_create_object

  • private subroutine json_value_create_object(json, p, name)

    Author
    Jacob Williams

    Allocate a json_value pointer and make it an object variable. The pointer should not already be allocated.

    Read more…

    Arguments

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

procedure, private :: json_value_create_real

  • private subroutine json_value_create_real(json, p, val, name)

    Author
    Jacob Williams

    Allocate a json_value pointer and make it a real(RK) variable. The pointer should not already be allocated.

    Read more…

    Arguments

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

procedure, private :: json_value_create_real32

procedure, private :: json_value_create_string

  • private subroutine json_value_create_string(json, p, val, name, trim_str, adjustl_str)

    Author
    Jacob Williams

    Allocate a json_value pointer and make it a string variable. The pointer should not already be allocated.

    Read more…

    Arguments

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

    if TRIM() should be called for the val

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

    if ADJUSTL() should be called for the val

procedure, private :: json_value_destroy

  • private pure recursive subroutine json_value_destroy(json, p, destroy_next)

    Author
    Jacob Williams
    Date
    1/22/2014

    Destroy a json_value linked-list structure.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: p

    variable to destroy

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

    if true, then p%next is also destroyed (default is true)

procedure, private :: json_value_get_child

  • private subroutine json_value_get_child(json, p, child)

    Returns pointer to the first child of the object (or null() if it is not associated).

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), intent(in), pointer :: p

    object or array JSON data

    type(json_value), pointer :: child

    pointer to the child

procedure, private :: json_value_get_child_by_index

  • private subroutine json_value_get_child_by_index(json, p, idx, child, found)

    Returns a child in the object or array given the index.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), intent(in), pointer :: p

    object or array JSON data

    integer(kind=IK), intent(in) :: idx

    index of the child (this is a 1-based Fortran style array index).

    type(json_value), pointer :: child

    pointer to the child

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

    true if the value was found (if not present, an exception will be thrown if it was not found. If present and not found, no exception will be thrown).

procedure, private :: json_value_get_child_by_name

  • private subroutine json_value_get_child_by_name(json, p, name, child, found)

    Returns a child in the object or array given the name string.

    Read more…

    Arguments

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

    the name of a child of p

    type(json_value), pointer :: child

    pointer to the child

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

    true if the value was found (if not present, an exception will be thrown if it was not found. If present and not found, no exception will be thrown).

procedure, private :: json_value_insert_after

  • private subroutine json_value_insert_after(json, p, element)

    Inserts element after p, and updates the JSON structure accordingly.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: p

    a value from a JSON structure (presumably, this is a child of an object or array).

    type(json_value), pointer :: element

    the element to insert after p

procedure, private :: json_value_insert_after_child_by_index

  • private subroutine json_value_insert_after_child_by_index(json, p, idx, element)

    Inserts element after the idx-th child of p, and updates the JSON structure accordingly. This is just a wrapper for json_value_insert_after.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: p

    a JSON object or array.

    integer(kind=IK), intent(in) :: idx

    the index of the child of p to insert the new element after (this is a 1-based Fortran style array index)

    type(json_value), pointer :: element

    the element to insert

procedure, private :: json_value_print

  • private recursive subroutine json_value_print(json, p, iunit, str, indent, need_comma, colon, is_array_element, is_compressed_vector, iloc)

    Print the JSON structure to a string or a file.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), intent(in), pointer :: p
    integer(kind=IK), intent(in) :: iunit

    file unit to write to (the file is assumed to be open)

    character(kind=CK, len=:), intent(inout), allocatable :: str

    if iunit==unit2str (-1) then the structure is printed to this string rather than a file. This mode is used by json_value_to_string.

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

    indention level

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

    if it needs a comma after it

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

    if the colon was just written

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

    if this is an array element

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

    if True, this is an element from an array being printed on one line [default is False]

    integer(kind=IK), intent(inout) :: iloc

    current index in str. should be set to 0 initially. [only used when str is used.]

procedure, private :: json_value_remove_if_present

  • private subroutine json_value_remove_if_present(json, p, path)

    Author
    Jacob Williams
    Date
    12/6/2014

    Given the path string, remove the variable from json_value, if it exists.

    Arguments

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

    the path to the variable to remove

procedure, private :: json_value_rename

  • private subroutine json_value_rename(json, p, name)

    Author
    Jacob Williams
    Date
    4/29/2016

    Rename a json_value.

    Arguments

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

    new variable name

generic, public :: load => json_parse_file

Parse the JSON file and populate the json_value tree.

  • private subroutine json_parse_file(json, file, p, unit)

    Parse the JSON file and populate the json_value tree.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    character(kind=CDK, len=*), intent(in) :: file

    JSON file name

    type(json_value), pointer :: p

    output structure

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

    file unit number (/= 0)

get matrix info about a json_value

  • private subroutine json_matrix_info(json, p, is_matrix, var_type, n_sets, set_size, name)

    Author
    Jacob Williams
    Date
    10/16/2015

    Alternate version of json_info that returns matrix information about a json_value.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: p

    a JSON linked list

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

    true if it is a valid matrix

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

    variable type of data in the matrix (if all elements have the same type)

    integer(kind=IK), intent(out), optional :: n_sets

    number of data sets (i.e., matrix rows if using row-major order)

    integer(kind=IK), intent(out), optional :: set_size

    size of each data set (i.e., matrix cols if using row-major order)

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

    variable name

  • private subroutine json_matrix_info_by_path(json, p, path, is_matrix, found, var_type, n_sets, set_size, name)

    Returns matrix information about a json_value, given the path.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: p

    a JSON linked list

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

    path to the variable

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

    true if it is a valid matrix

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

    true if it was found

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

    variable type of data in the matrix (if all elements have the same type)

    integer(kind=IK), intent(out), optional :: n_sets

    number of data sets (i.e., matrix rows if using row-major order)

    integer(kind=IK), intent(out), optional :: set_size

    size of each data set (i.e., matrix cols if using row-major order)

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

    variable name

  • private subroutine wrap_json_matrix_info_by_path(json, p, path, is_matrix, found, var_type, n_sets, set_size, name)

    Alternate version of json_matrix_info_by_path where “path” is kind=CDK.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: p

    a JSON linked list

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

    path to the variable

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

    true if it is a valid matrix

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

    true if it was found

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

    variable type of data in the matrix (if all elements have the same type)

    integer(kind=IK), intent(out), optional :: n_sets

    number of data sets (i.e., matrix rows if using row-major order)

    integer(kind=IK), intent(out), optional :: set_size

    size of each data set (i.e., matrix cols if using row-major order)

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

    variable name

procedure, private :: name_equal

  • private function name_equal(json, p, name) result(is_equal)

    Author
    Jacob Williams

    Returns true if name is equal to p%name, using the specified settings for case sensitivity and trailing whitespace.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), intent(in) :: p

    the json object

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

    the name to check for

    Return Value logical(kind=LK)

    true if the string are lexically equal

procedure, private :: name_strings_equal

  • private function name_strings_equal(json, name1, name2) result(is_equal)

    Author
    Jacob Williams
    Date
    8/25/2017

    Returns true if the name strings name1 is equal to name2, using the specified settings for case sensitivity and trailing whitespace.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    character(kind=CK, len=*), intent(in) :: name1

    the name to check

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

    the name to check

    Return Value logical(kind=LK)

    true if the string are lexically equal

Same as load and deserialize but only here for backward compatibility.

  • private subroutine json_parse_file(json, file, p, unit)

    Parse the JSON file and populate the json_value tree.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    character(kind=CDK, len=*), intent(in) :: file

    JSON file name

    type(json_value), pointer :: p

    output structure

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

    file unit number (/= 0)

  • private subroutine json_parse_string(json, p, str)

    Parse the JSON string and populate the json_value tree.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: p

    output structure

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

    string with JSON data

  • private subroutine wrap_json_parse_string(json, p, str)

    Alternate version of json_parse_string, where str is kind=CDK.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: p

    output structure

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

    string with JSON data

procedure, private :: parse_array

  • private recursive subroutine parse_array(json, unit, str, array)

    Core parsing routine.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    integer(kind=IK), intent(in) :: unit

    file unit number (if parsing from a file)

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

    JSON string (if parsing from a string)

    type(json_value), pointer :: array

procedure, private :: parse_end => json_parse_end

  • private subroutine json_parse_end(json, unit, str)

    An error checking routine to call after a file (or string) has been parsed. It will throw an exception if there are any other non-whitespace characters in the file.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    integer(kind=IK), intent(in) :: unit

    file unit number

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

    string containing JSON data (only used if unit=0)

procedure, private :: parse_for_chars

  • private subroutine parse_for_chars(json, unit, str, chars)

    Core parsing routine.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    integer(kind=IK), intent(in) :: unit

    file unit number (if parsing from a file)

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

    JSON string (if parsing from a string)

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

    the string to check for.

procedure, private :: parse_number

  • private subroutine parse_number(json, unit, str, value)

    Author
    Jacob Williams
    Date
    1/20/2014

    Read a numerical value from the file (or string). The routine will determine if it is an integer or a real, and allocate the type accordingly.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    integer(kind=IK), intent(in) :: unit

    file unit number (if parsing from a file)

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

    JSON string (if parsing from a string)

    type(json_value), pointer :: value

procedure, private :: parse_object

  • private recursive subroutine parse_object(json, unit, str, parent, expecting_next_element)

    Core parsing routine.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    integer(kind=IK), intent(in) :: unit

    file unit number (if parsing from a file)

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

    JSON string (if parsing from a string)

    type(json_value), pointer :: parent

    the parsed object will be added as a child of this

    logical(kind=LK), intent(in) :: expecting_next_element

    if true, this object is preceeded by a comma, so we expect a valid object to exist. used to check for trailing delimiters.

procedure, private :: parse_string

  • private subroutine parse_string(json, unit, str, string)

    Parses a string while reading a JSON file.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    integer(kind=IK), intent(in) :: unit

    file unit number (if parsing from a file)

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

    JSON string (if parsing from a string)

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

    the string (unescaped if necessary)

procedure, private :: parse_value

  • private recursive subroutine parse_value(json, unit, str, value)

    Core parsing routine.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    integer(kind=IK), intent(in) :: unit

    file unit number

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

    string containing JSON data (only used if unit=0)

    type(json_value), pointer :: value

    JSON data that is extracted

procedure, private :: pop_char

  • private subroutine pop_char(json, unit, str, skip_ws, skip_comments, eof, popped)

    Get the next character from the file (or string).

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    integer(kind=IK), intent(in) :: unit

    file unit number (if parsing from a file)

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

    JSON string (if parsing from a string) – only used if unit=0

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

    to ignore whitespace [default False]

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

    to ignore comment lines [default False]

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

    true if the end of the file has been reached.

    character(kind=CK, len=1), intent(out) :: popped

    the popped character returned

procedure, private :: prepare_parser => json_prepare_parser

  • private subroutine json_prepare_parser(json)

    Internal routine to be called before parsing JSON. Currently, all this does it allocate the comment_char if none was specified.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json

Print the json_value to an output unit or file.

Example

    type(json_core) :: json
    type(json_value) :: p
    !...
    call json%print(p,'test.json')  !this is [[json_print_to_filename]]
  • private subroutine json_print_to_console(json, p)

    Print the json_value structure to the console (output_unit).

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), intent(in), pointer :: p
  • private subroutine json_print_to_unit(json, p, iunit)

    Author
    Jacob Williams
    Date
    6/20/2014

    Print the json_value structure to a file.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), intent(in), pointer :: p
    integer(kind=IK), intent(in) :: iunit

    the file unit (the file must already have been opened, can’t be -1).

  • private subroutine json_print_to_filename(json, p, filename)

    Author
    Jacob Williams
    Date
    12/23/2014

    Print the json_value structure to a file.

    Arguments

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

    the filename to print to (should not already be open)

procedure, public :: print_error_message => json_print_error_message

simply routine to print error messages

  • private subroutine json_print_error_message(json, io_unit)

    Author
    Jacob Williams

    Print any error message, and then clear the exceptions.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    integer, intent(in), optional :: io_unit

    unit number for printing error message

procedure, public :: print_to_string => json_value_to_string

The same as serialize, but only here for backward compatibility

  • private subroutine json_value_to_string(json, p, str)

    Author
    Jacob Williams
    Date
    2/12/2014

    Print the json_value structure to an allocatable string.

    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

procedure, private :: push_char

  • private subroutine push_char(json, c)

    Core routine.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    character(kind=CK, len=1), intent(in) :: c

    to character to push

procedure, public :: remove => json_value_remove

Remove a json_value from a linked-list structure.

  • private subroutine json_value_remove(json, p, destroy)

    Author
    Jacob Williams
    Date
    9/9/2014

    Remove a json_value (and all its children) from a linked-list structure, preserving the rest of the structure.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: p
    logical(kind=LK), intent(in), optional :: destroy

    Option to destroy p after it is removed:

    Read more…

generic, public :: remove_if_present => json_value_remove_if_present, wrap_json_value_remove_if_present

If the child variable is present, then remove it.

Rename a json_value variable.

  • private subroutine json_value_rename(json, p, name)

    Author
    Jacob Williams
    Date
    4/29/2016

    Rename a json_value.

    Arguments

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

    new variable name

  • private subroutine wrap_json_value_rename(json, p, name)

    Author
    Jacob Williams
    Date
    4/29/2016

    Alternate version of json_value_rename, where name is kind=CDK.

    Arguments

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

    new variable name

  • private subroutine json_rename_by_path(json, me, path, name, found)

    Rename a json_value, given the path.

    Read more…

    Arguments

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

    path to the variable to rename

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

    the new name

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

    if there were no errors

  • private subroutine wrap_json_rename_by_path(json, me, path, name, found)

    Alternate version of json_rename_by_path, where “path” and “name” are kind=CDK

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), intent(in), pointer :: me
    character(kind=CDK, len=*), intent(in) :: path
    character(kind=CDK, len=*), intent(in) :: name
    logical(kind=LK), intent(out), optional :: found
  • private subroutine json_rename_by_path_name_ascii(json, me, path, name, found)

    Alternate version of json_rename_by_path, where “name” is kind=CDK

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), intent(in), pointer :: me
    character(kind=CK, len=*), intent(in) :: path
    character(kind=CDK, len=*), intent(in) :: name
    logical(kind=LK), intent(out), optional :: found
  • private subroutine json_rename_by_path_path_ascii(json, me, path, name, found)

    Alternate version of json_rename_by_path, where “path” is kind=CDK

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), intent(in), pointer :: me
    character(kind=CDK, len=*), intent(in) :: path
    character(kind=CK, len=*), intent(in) :: name
    logical(kind=LK), intent(out), optional :: found

procedure, public :: replace => json_value_replace

Replace a json_value in a linked-list structure.

  • private subroutine json_value_replace(json, p1, p2, destroy)

    Replace p1 with p2 in a JSON structure.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: p1

    the item to replace

    type(json_value), pointer :: p2

    item to take the place of p1

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

    Should p1 also be destroyed (default is True). Normally, this should be true to avoid a memory leak.

procedure, public :: reverse => json_value_reverse

Reverse the order of the children of an array of object.

  • private subroutine json_value_reverse(json, p)

    Author
    Jacob Williams
    Date
    4/11/2017

    Reverse the order of the children of an array or object.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: p

procedure, public :: serialize => json_value_to_string

Print the json_value structure to an allocatable string

  • private subroutine json_value_to_string(json, p, str)

    Author
    Jacob Williams
    Date
    2/12/2014

    Print the json_value structure to an allocatable string.

    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

generic, public :: string_info => json_string_info

get string info about a json_value

  • private subroutine json_string_info(json, p, ilen, max_str_len, found)

    Author
    Jacob Williams
    Date
    12/18/2016

    Returns information about character strings returned from a json_value.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: p
    integer(kind=IK), intent(out), optional, dimension(:), allocatable :: ilen

    if p is an array, this is the actual length of each character string in the array. if not an array, this is returned unallocated.

    integer(kind=IK), intent(out), optional :: max_str_len

    The maximum length required to hold the string representation returned by a call to a get routine. If a scalar, this is just the length of the scalar. If a vector, this is the maximum length of any element.

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

    true if there were no errors. if not present, an error will throw an exception

procedure, private :: string_to_dble

  • private function string_to_dble(json, str) result(rval)

    Convert a string into a real(RK) value.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    character(kind=CK, len=*), intent(in) :: str

    a string

    Return Value real(kind=RK)

    str converted to a real(RK)

procedure, private :: string_to_int

  • private function string_to_int(json, str) result(ival)

    Convert a string into an integer.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    character(kind=CK, len=*), intent(in) :: str

    a string

    Return Value integer(kind=IK)

    str converted to an integer

procedure, public :: swap => json_value_swap

Swap two json_value pointers in a structure (or two different structures).

  • private subroutine json_value_swap(json, p1, p2)

    Author
    Jacob Williams
    Date
    4/26/2016

    Swap two elements in a JSON structure. All of the children are carried along as well.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: p1

    swap with p2

    type(json_value), pointer :: p2

    swap with p1

generic, public :: throw_exception => json_throw_exception, wrap_json_throw_exception

Throw an exception.

  • private subroutine json_throw_exception(json, msg, found)

    Author
    Jacob Williams
    Date
    12/4/2013

    Throw an exception in the json_core. This routine sets the error flag, and prevents any subsequent routine from doing anything, until json_clear_exceptions is called.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    character(kind=CK, len=*), intent(in) :: msg

    the error message

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

    if the caller is handling the exception with an optimal return argument. If so, json%stop_on_error is ignored.

  • private subroutine wrap_json_throw_exception(json, msg, found)

    Alternate version of json_throw_exception, where msg is kind=CDK.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    character(kind=CDK, len=*), intent(in) :: msg

    the error message

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

    if the caller is handling the exception with an optimal return argument. If so, json%stop_on_error is ignored.

procedure, private :: to_array

  • private subroutine to_array(json, p, name)

    Author
    Jacob Williams

    Change the json_value variable to an array.

    Arguments

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

    if the name is also to be changed.

procedure, private :: to_integer

  • private subroutine to_integer(json, p, val, name)

    Author
    Jacob Williams

    Change the json_value variable to an integer.

    Arguments

    Type IntentOptional 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.

procedure, private :: to_logical

  • private subroutine to_logical(json, p, val, name)

    Author
    Jacob Williams

    Change the json_value variable to a logical.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: p
    logical(kind=LK), intent(in), optional :: val

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

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

    if the name is also to be changed.

procedure, private :: to_null

  • private subroutine to_null(json, p, name)

    Author
    Jacob Williams

    Change the json_value variable to a null.

    Arguments

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

    if the name is also to be changed.

procedure, private :: to_object

  • private subroutine to_object(json, p, name)

    Author
    Jacob Williams

    Change the json_value variable to an object.

    Arguments

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

    if the name is also to be changed.

procedure, private :: to_real

  • private subroutine to_real(json, p, val, name)

    Author
    Jacob Williams

    Change the json_value variable to a real.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: p
    real(kind=RK), intent(in), optional :: val

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

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

    if the name is also to be changed.

procedure, private :: to_string

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

    Author
    Jacob Williams

    Change the json_value variable to a string.

    Read more…

    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)

procedure, public :: traverse => json_traverse

to traverse all elements of a JSON structure

These are like the add methods, except if a variable with the same path is already present, then its value is simply updated. Note that currently, these only work for scalar variables. These routines can also change the variable’s type (but an error will be thrown if the existing variable is not a scalar).

See also

  • add_by_path - this one can be used to change arrays and objects to scalars if so desired.

Note

Unlike some routines, the found output is not optional, so it doesn’t present exceptions from being thrown.

Note

These have been mostly supplanted by the add_by_path methods, which do a similar thing (and can be used for scalars and vectors, etc.)

  • private subroutine json_update_logical(json, p, path, val, found)

    Author
    Jacob Williams
    Date
    12/6/2014

    Given the path string, if the variable is present, and is a scalar, then update its value. If it is not present, then create it and set its value.

    Read more…

    Arguments

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

    path to the variable in the structure

    logical(kind=LK), intent(in) :: val

    the new value

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

    if the variable was found and was a scalar.

  • private subroutine wrap_json_update_logical(json, p, path, val, found)

    Alternate version of json_update_logical, where path is kind=CDK.

    Arguments

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

    path to the variable in the structure

    logical(kind=LK), intent(in) :: val

    the new value

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

    if the variable was found and was a scalar.

  • private subroutine json_update_real32(json, p, path, val, found)

    Alternate version of json_update_real, where val is real32.

    Arguments

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

    path to the variable in the structure

    real(kind=real32), intent(in) :: val

    the new value

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

    if the variable was found and was a scalar.

  • private subroutine wrap_json_update_real32(json, p, path, val, found)

    Alternate version of json_update_real32, where path is kind=CDK.

    Arguments

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

    path to the variable in the structure

    real(kind=real32), intent(in) :: val

    the new value

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

    if the variable was found and was a scalar.

  • private subroutine json_update_real(json, p, path, val, found)

    Author
    Jacob Williams
    Date
    12/6/2014

    Given the path string, if the variable is present, and is a scalar, then update its value. If it is not present, then create it and set its value.

    Read more…

    Arguments

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

    path to the variable in the structure

    real(kind=RK), intent(in) :: val

    the new value

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

    if the variable was found and was a scalar.

  • private subroutine wrap_json_update_real(json, p, path, val, found)

    Alternate version of json_update_real, where path is kind=CDK.

    Arguments

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

    path to the variable in the structure

    real(kind=RK), intent(in) :: val

    the new value

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

    if the variable was found and was a scalar.

  • private subroutine json_update_integer(json, p, path, val, found)

    Author
    Jacob Williams
    Date
    12/6/2014

    Given the path string, if the variable is present, and is a scalar, then update its value. If it is not present, then create it and set its value.

    Read more…

    Arguments

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

    path to the variable in the structure

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

    the new value

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

    if the variable was found and was a scalar.

  • private subroutine wrap_json_update_integer(json, p, path, val, found)

    Alternate version of json_update_integer, where path is kind=CDK.

    Arguments

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

    path to the variable in the structure

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

    the new value

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

    if the variable was found and was a scalar.

  • private subroutine json_update_string(json, p, path, val, found, trim_str, adjustl_str)

    Author
    Jacob Williams
    Date
    12/6/2014

    Given the path string, if the variable is present, and is a scalar, then update its value. If it is not present, then create it and set its value.

    Read more…

    Arguments

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

    path to the variable in the structure

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

    the new value

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

    if the variable was found and was a scalar.

    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)

  • private subroutine wrap_json_update_string(json, p, path, val, found, trim_str, adjustl_str)

    Alternate version of json_update_string, where path and value are kind=CDK.

    Arguments

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

    path to the variable in the structure

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

    the new value

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

    if the variable was found and was a scalar.

    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)

  • private subroutine json_update_string_name_ascii(json, p, path, val, found, trim_str, adjustl_str)

    Alternate version of json_update_string, where path is kind=CDK.

    Arguments

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

    path to the variable in the structure

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

    the new value

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

    if the variable was found and was a scalar.

    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)

  • private subroutine json_update_string_val_ascii(json, p, path, val, found, trim_str, adjustl_str)

    Alternate version of json_update_string, where val is kind=CDK.

    Arguments

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

    path to the variable in the structure

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

    the new value

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

    if the variable was found and was a scalar.

    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)

generic, public :: valid_path => json_valid_path, wrap_json_valid_path

verify if a path is valid (i.e., a variable with this path exists in the file).

  • private function json_valid_path(json, p, path) result(found)

    Returns true if the path is present in the p JSON structure.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), intent(in), pointer :: p

    a JSON linked list

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

    path to the variable

    Return Value logical(kind=LK)

    true if it was found

  • private function wrap_json_valid_path(json, p, path) result(found)

    Alternate version of json_valid_path where “path” is kind=CDK.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), intent(in), pointer :: p

    a JSON linked list

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

    path to the variable

    Return Value logical(kind=LK)

    true if it was found

procedure, public :: validate => json_value_validate

Check that a json_value linked list is valid (i.e., is properly constructed). This may be useful if it has been constructed externally.

  • private subroutine json_value_validate(json, p, is_valid, error_msg)

    Author
    Jacob Williams
    Date
    5/2/2016

    Validate a json_value linked list by checking to make sure all the pointers are properly associated, arrays and objects have the correct number of children, and the correct data is allocated for the variable types.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), intent(in), pointer :: p
    logical(kind=LK), intent(out) :: is_valid

    True if the structure is valid.

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

    if not valid, this will contain a description of the problem

procedure, private :: wrap_json_add_integer_by_path

  • private subroutine wrap_json_add_integer_by_path(json, me, path, value, found, was_created)

    Wrapper to json_add_integer_by_path where “path” is kind=CDK.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: me

    the JSON structure

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

    the path to the variable

    integer(kind=IK), intent(in) :: value

    the value to add

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

    if the variable was found

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

    if the variable had to be created

procedure, private :: wrap_json_add_integer_vec_by_path

  • private subroutine wrap_json_add_integer_vec_by_path(json, me, path, value, found, was_created)

    Wrapper for json_add_integer_vec_by_path where “path” is kind=CDK).

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: me

    the JSON structure

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

    the path to the variable

    integer(kind=IK), intent(in), dimension(:) :: value

    the vector to add

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

    if the variable was found

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

    if the variable had to be created

procedure, private :: wrap_json_add_logical_by_path

  • private subroutine wrap_json_add_logical_by_path(json, me, path, value, found, was_created)

    Wrapper to json_add_logical_by_path where “path” is kind=CDK.

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: me

    the JSON structure

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

    the path to the variable

    logical(kind=LK), intent(in) :: value

    the value to add

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

    if the variable was found

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

    if the variable had to be created

procedure, private :: wrap_json_add_logical_vec_by_path

  • private subroutine wrap_json_add_logical_vec_by_path(json, me, path, value, found, was_created)

    Wrapper for json_add_logical_vec_by_path where “path” is kind=CDK).

    Arguments

    Type IntentOptional Attributes Name
    class(json_core), intent(inout) :: json
    type(json_value), pointer :: me

    the JSON structure

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

    the path to the variable

    logical(kind=LK), intent(in), dimension(:) :: value

    the vector to add

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

    if the variable was found

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

    if the variable had to be created

procedure, private :: wrap_json_add_member_by_path