A Fortran 2008 JSON (JavaScript Object Notation) API.
This module provides an interface for reading and writing JSON files.
-DUSE_UCS4
is an optional preprocessor flag.
When present, Unicode support is enabled. Note that this
is currently only supported with the gfortran compiler.
Example: gfortran -DUSE_UCS4 ...
The documentation given here assumes USE_UCS4
is not defined.CK
and CDK
are the JSON-Fortran character kind and JSON-Fortran default
character kind respectively. Client code MUST ensure characters of kind=CK
are used for all character variables and strings passed to the JSON-Fortran
library EXCEPT for file names which must be of 'DEFAULT'
character kind,
provided here as CDK
. In particular, any variable that is a: json path, string
value or object name passed to the JSON-Fortran library MUST be of type CK
.intent(in)
character arguments of the default (CDK
) kind. If you find a procedure which does
not accept an intent(in)
literal string argument of default kind, please
file an issue on github.JSON-Fortran License:
JSON-Fortran: A Fortran 2008 JSON API http://github.com/jacobwilliams/json-fortran Copyright (c) 2014-2015, Jacob Williams All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * The names of its contributors may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Original FSON License:
Copyright (c) 2012 Joseph A. Levin Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
integer, | private, | parameter | :: | RK | = | real64 | Default real kind [8 bytes] |
integer, | private, | parameter | :: | IK | = | int32 | Default integer kind [4 bytes]. |
integer, | public, | parameter | :: | CDK | = | selected_char_kind("0") | Processor dependendant 'DEFAULT' character kind. This is 1 byte for the Intel and Gfortran compilers. |
integer, | private, | parameter | :: | LK | = | logical_kinds(min(3,size(logical_kinds))) | Default logical kind. This is 4 bytes for the Intel and Gfortran compilers (and perhaps others). The declaration ensures a valid kind if the compiler doesn't have a logical_kinds(3). |
character(kind=CDK,len=*), | private, | parameter | :: | json_fortran_string_kind | = | 'DEFAULT' | String kind preprocessor macro. this is the string kind to use unless compiling with GFortran AND UCS4/ISO 10646 support is requested |
integer, | public, | parameter | :: | CK | = | selected_char_kind(json_fortran_string_kind) | Default character kind used by JSON-Fortran. If ISO 10646 (UCS4) support is available, use that, otherwise, gracefully fall back on 'DEFAULT' characters. Currently only gfortran >= 4.9.2 will correctly support UCS4 which is stored in 4 bytes. (and perhaps others). |
logical, | private, | parameter | :: | use_unformatted_stream | = | .true. | If Unicode is not enabled, then JSON files are opened using access='STREAM' and form='UNFORMATTED'. This allows the file to be read faster. |
character(kind=CDK,len=*), | private, | parameter | :: | access_spec | = | 'STREAM' | If Unicode is not enabled, then JSON files are opened using access='STREAM' and form='UNFORMATTED'. This allows the file to be read faster. |
character(kind=CDK,len=*), | private, | parameter | :: | form_spec | = | 'UNFORMATTED' | If Unicode is not enabled, then JSON files are opened using access='STREAM' and form='UNFORMATTED'. This allows the file to be read faster. |
integer(kind=IK), | public, | parameter | :: | json_unknown | = | 0 | Unknown JSON data type (see json_file_variable_info and json_info) |
integer(kind=IK), | public, | parameter | :: | json_null | = | 1 | Null JSON data type (see json_file_variable_info and json_info) |
integer(kind=IK), | public, | parameter | :: | json_object | = | 2 | Object JSON data type (see json_file_variable_info and json_info) |
integer(kind=IK), | public, | parameter | :: | json_array | = | 3 | Array JSON data type (see json_file_variable_info and json_info) |
integer(kind=IK), | public, | parameter | :: | json_logical | = | 4 | Logical JSON data type (see json_file_variable_info and json_info) |
integer(kind=IK), | public, | parameter | :: | json_integer | = | 5 | Integer JSON data type (see json_file_variable_info and json_info) |
integer(kind=IK), | public, | parameter | :: | json_double | = | 6 | Double JSON data type (see json_file_variable_info and json_info) |
integer(kind=IK), | public, | parameter | :: | json_string | = | 7 | String JSON data type |
character(kind=CDK,len=*), | public, | parameter | :: | json_ext | = | '.json' | JSON file extension |
character(kind=CK,len=*), | private, | parameter | :: | space | = | ' ' | |
character(kind=CK,len=*), | private, | parameter | :: | start_object | = | '{' | |
character(kind=CK,len=*), | private, | parameter | :: | end_object | = | '}' | |
character(kind=CK,len=*), | private, | parameter | :: | start_array | = | '[' | |
character(kind=CK,len=*), | private, | parameter | :: | end_array | = | ']' | |
character(kind=CK,len=*), | private, | parameter | :: | delimiter | = | ',' | |
character(kind=CK,len=*), | private, | parameter | :: | colon_char | = | ':' | |
character(kind=CK,len=*), | private, | parameter | :: | bspace | = | achar(8) | |
character(kind=CK,len=*), | private, | parameter | :: | horizontal_tab | = | achar(9) | |
character(kind=CK,len=*), | private, | parameter | :: | newline | = | achar(10) | |
character(kind=CK,len=*), | private, | parameter | :: | formfeed | = | achar(12) | |
character(kind=CK,len=*), | private, | parameter | :: | carriage_return | = | achar(13) | |
character(kind=CK,len=*), | private, | parameter | :: | quotation_mark | = | achar(34) | |
character(kind=CK,len=*), | private, | parameter | :: | slash | = | achar(47) | |
character(kind=CK,len=*), | private, | parameter | :: | backslash | = | achar(92) | |
character(kind=CK,len=4), | private | :: | null_str | = | 'null' | ||
character(kind=CK,len=4), | private | :: | true_str | = | 'true' | ||
character(kind=CK,len=5), | private | :: | false_str | = | 'false' | ||
integer, | private | :: | i_ | ||||
character(kind=CK,len=*), | private, | parameter | :: | control_chars(32) | = | [(achar(i_), i_=1, 31), achar(127)] | |
integer(kind=IK), | private, | parameter | :: | spaces_per_tab | = | 2 | |
logical(kind=LK), | private | :: | compact_real | = | .true. | to use the "compact" form of real numbers for output |
|
integer(kind=IK), | private, | parameter | :: | rp_safety_factor | = | 1 | |
integer(kind=IK), | private, | parameter | :: | rp_addl_safety | = | 1 | |
integer(kind=IK), | private, | parameter | :: | real_precision | = | rp_safety_factor*precision(1.0_RK)+rp_addl_safety | |
integer(kind=IK), | private, | parameter | :: | maxexp | = | maxexponent(1.0_RK) | |
integer(kind=IK), | private, | parameter | :: | minexp | = | minexponent(1.0_RK) | |
integer(kind=IK), | private, | parameter | :: | real_exponent_digits | = | floor(1+log10(real(max(maxexp,abs(maxexp)),kind=RK))) | |
integer(kind=IK), | private, | parameter | :: | max_numeric_str_len | = | real_precision+real_exponent_digits+6 | 6 = sign + leading 0 + decimal + 'E' + exponent sign + 1 extra |
character(kind=CDK,len=*), | private, | parameter | :: | int_fmt | = | '(ss,I0)' | minimum width format for integers |
character(kind=CK,len=*), | private, | parameter | :: | star | = | '*' | for invalid numbers and list-directed real output |
character(kind=CDK,len=:), | private, | allocatable | :: | real_fmt | the format string to use for real numbers it is set in json_initialize |
||
logical(kind=LK), | private | :: | is_verbose | = | .false. | if true, all exceptions are immediately printed to console |
|
logical(kind=LK), | private | :: | exception_thrown | = | .true. | the error flag (by default, this is true to make sure that json_initialize is called. |
|
character(kind=CK,len=:), | private, | allocatable | :: | err_message | the error message |
||
integer(kind=IK), | private | :: | char_count | = | 0 | ||
integer(kind=IK), | private | :: | line_count | = | 1 | ||
integer(kind=IK), | private | :: | pushed_index | = | 0 | ||
character(kind=CK,len=10), | private | :: | pushed_char | = | '' | ||
integer(kind=IK), | private, | parameter | :: | chunk_size | = | 100 | for allocatable strings: allocate chunks of this size |
integer(kind=IK), | private | :: | ipos | = | 1 | for allocatable strings: next character to read |
|
integer(kind=IK), | private, | parameter | :: | unit2str | = | -1 | unit number to cause stuff to be output to strings rather than files. See 9.5.6.12 in the F2003/08 standard |
Structure constructor to initialize a json_file object with an existing json_value object
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | intent(in), | optional | pointer | :: | p |
|
Cast a json_value object as a json_file object
Get a child, either by index or name string. Both of these return a json_value pointer.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | intent(in), | pointer | :: | me | object or array JSON data |
|
integer(kind=IK), | intent(in) | :: | idx | index of the child |
||
type(json_value), | , | pointer | :: | p | pointer to the child |
Returns a child in the object or array given the index.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | intent(in), | pointer | :: | me | ||
character(kind=CK,len=*), | intent(in) | :: | name | the name of a child of "me" |
||
type(json_value), | , | pointer | :: | p | pointer to the child |
Returns a child in the object or array given the name string.
Add objects to a linked list of json_values.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | me | ||
type(json_value), | , | pointer | :: | member | the child member to add |
Adds "member" as a child of "me".
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | me | ||
character(kind=CK,len=*), | intent(in) | :: | name | |||
integer(kind=IK), | intent(in) | :: | val |
Add an integer value child to the json_value variable
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | me | ||
character(kind=CK,len=*), | intent(in) | :: | name | name of the variable |
||
integer(kind=IK), | intent(in), | dimension(:) | :: | val | value |
Add an integer vector to the structure.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | me | ||
character(kind=CK,len=*), | intent(in) | :: | name | variable name |
||
real(kind=RK), | intent(in) | :: | val | real value |
Add a real value child to the json_value variable
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | me | ||
character(kind=CK,len=*), | intent(in) | :: | name | |||
real(kind=RK), | intent(in), | dimension(:) | :: | val |
Add a real vector to the structure.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | me | ||
character(kind=CK,len=*), | intent(in) | :: | name | name of the variable |
||
logical(kind=LK), | intent(in) | :: | val | value |
Add a logical value child to the json_value variable
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | me | ||
character(kind=CK,len=*), | intent(in) | :: | name | name of the vector |
||
logical(kind=LK), | intent(in), | dimension(:) | :: | val | value |
Add a logical vector to the structure.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | me | ||
character(kind=CK,len=*), | intent(in) | :: | name | name of the variable |
||
character(kind=CK,len=*), | intent(in) | :: | val | value |
Add a character string child to the json_value variable.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | me | ||
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 |
Add an array of character strings to the structure.
These are like json_add, except if a child with the same name 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).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | p | ||
character(kind=CK,len=*), | intent(in) | :: | name | |||
logical(kind=LK), | intent(in) | :: | val | |||
logical(kind=LK), | intent(out) | :: | found |
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.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | p | ||
character(kind=CK,len=*), | intent(in) | :: | name | |||
real(kind=RK), | intent(in) | :: | val | |||
logical(kind=LK), | intent(out) | :: | found |
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.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | p | ||
character(kind=CK,len=*), | intent(in) | :: | name | |||
integer(kind=IK), | intent(in) | :: | val | |||
logical(kind=LK), | intent(out) | :: | found |
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.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | p | ||
character(kind=CK,len=*), | intent(in) | :: | name | |||
character(kind=CK,len=*), | intent(in) | :: | val | |||
logical(kind=LK), | intent(out) | :: | found |
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.
Get data from a json_value linked list.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | intent(in), | pointer | :: | me | ||
character(kind=CK,len=*), | intent(in) | :: | path | |||
type(json_value), | intent(out), | pointer | :: | p | ||
logical(kind=LK), | intent(out), | optional | :: | found | true if it was found |
Returns the json_value pointer given the path string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | intent(in), | pointer | :: | me | ||
integer(kind=IK), | intent(out) | :: | value |
Get an integer value from a json_value.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
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 |
Get an integer value from a json_value, given the path string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | me | ||
integer(kind=IK), | intent(out), | dimension(:), allocatable | :: | vec |
Get an integer vector from a json_value.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | me | ||
character(kind=CK,len=*), | intent(in) | :: | path | |||
integer(kind=IK), | intent(out), | dimension(:), allocatable | :: | vec | ||
logical(kind=LK), | intent(out), | optional | :: | found |
Get an integer vector from a json_value, given the path string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | me | ||
real(kind=RK), | intent(out) | :: | value |
Get a double value from a json_value.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
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 |
Get a double value from a json_value, given the path.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | me | ||
real(kind=RK), | intent(out), | dimension(:), allocatable | :: | vec |
Get a double vector from a json_value.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | me | ||
character(kind=CK,len=*), | intent(in) | :: | path | |||
real(kind=RK), | intent(out), | dimension(:), allocatable | :: | vec | ||
logical(kind=LK), | intent(out), | optional | :: | found |
Get a double vector from a json_value, given the path.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | intent(in), | pointer | :: | me | ||
logical(kind=LK) | :: | value |
Get a logical value from a json_value.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | intent(in), | pointer | :: | me | ||
character(kind=CK,len=*), | intent(in) | :: | path | |||
logical(kind=LK) | :: | value | ||||
logical(kind=LK), | intent(out), | optional | :: | found |
Get a logical value from a json_value, given the path.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | intent(in), | pointer | :: | me | ||
logical(kind=LK), | intent(out), | dimension(:), allocatable | :: | vec |
Get a logical vector from json_value.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
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 |
Get a logical vector from a json_value, given the path.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | intent(in), | pointer | :: | me | ||
character(kind=CK,len=:), | intent(out), | allocatable | :: | value |
Get a character string from a json_value.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
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 |
Get a character string from a json_value, given the path.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | intent(in), | pointer | :: | me | ||
character(kind=CK,len=*), | intent(out), | dimension(:), allocatable | :: | vec |
Get a string vector from a json_file.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
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 |
Get a string vector from a json_file, given the path.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | intent(in), | pointer | :: | me | ||
procedure(array_callback_func) | :: | array_callback |
This routine calls the user-supplied array_callback_func subroutine for each element in the array.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | intent(in), | pointer | :: | me | ||
character(kind=CK,len=*), | intent(in) | :: | path | |||
procedure(array_callback_func) | :: | array_callback | ||||
logical(kind=LK), | intent(out), | optional | :: | found |
This routine calls the user-supplied array_callback subroutine for each element in the array (specified by the path).
Print the json_value structure to an allocatable string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | intent(in), | pointer | :: | me | ||
character(kind=CK,len=:), | intent(out), | allocatable | :: | str | prints structure to this string |
Print the json_value structure to an allocatable string.
Print the json_value to a file.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | intent(in), | pointer | :: | me | ||
integer(kind=IK), | intent(in) | :: | iunit | the file unit (the file must already have been opened, can't be -1). |
Print the json_value structure to a file.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | intent(in), | pointer | :: | me | ||
character(kind=CDK,len=*), | intent(in) | :: | filename | the filename to print to (should not already be open) |
Print the json_value structure to a file.
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.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | me | ||
logical(kind=LK), | intent(in), | optional | :: | destroy_next | if true, then me%next is also destroyed (default is true) |
Destroy a json_value linked-list structure.
Remove a json_value from a linked-list structure.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | me | ||
logical(kind=LK), | intent(in), | optional | :: | destroy | If destroy is not present, it is also destroyed. If destroy is present and true, it is destroyed. If destroy is present and false, it is not destroyed. |
Remove a json_value (and all its children) from a linked-list structure, preserving the rest of the structure.
If the child variable is present, then remove it.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | p | ||
character(kind=CK,len=*), | intent(in) | :: | name |
Given the path string, remove the variable from the json_value structure, if it exists.
Allocate a json_value pointer and make it a double variable. The pointer should not already be allocated.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | me | ||
real(kind=RK), | intent(in) | :: | val | |||
character(kind=CK,len=*), | intent(in) | :: | name |
Allocate a json_value pointer and make it a real(RK) variable. The pointer should not already be allocated.
Allocate a json_value pointer and make it an array variable. The pointer should not already be allocated.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | me | ||
character(kind=CK,len=*), | intent(in) | :: | name |
Allocate a json_value pointer and make it an array variable. The pointer should not already be allocated.
Allocate a json_value pointer and make it an object variable. The pointer should not already be allocated.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | me | ||
character(kind=CK,len=*), | intent(in) | :: | name |
Allocate a json_value pointer and make it an object variable. The pointer should not already be allocated.
Allocate a json_value pointer and make it a null variable. The pointer should not already be allocated.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | me | ||
character(kind=CK,len=*), | intent(in) | :: | name |
Allocate a json_value pointer and make it a null variable. The pointer should not already be allocated.
Allocate a json_value pointer and make it a string variable. The pointer should not already be allocated.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | me | ||
character(kind=CK,len=*), | intent(in) | :: | val | |||
character(kind=CK,len=*), | intent(in) | :: | name |
Allocate a json_value pointer and make it a string variable. The pointer should not already be allocated.
Allocate a json_value pointer and make it an integer variable. The pointer should not already be allocated.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | me | ||
integer(kind=IK), | intent(in) | :: | val | |||
character(kind=CK,len=*), | intent(in) | :: | name |
Allocate a json_value pointer and make it an integer(IK) variable. The pointer should not already be allocated.
Allocate a json_value pointer and make it a logical variable. The pointer should not already be allocated.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | me | ||
logical(kind=LK), | intent(in) | :: | val | variable value |
||
character(kind=CK,len=*), | intent(in) | :: | name | variable name |
Allocate a json_value pointer and make it a logical(LK) variable. The pointer should not already be allocated.
Parse the JSON file and populate the json_value tree.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
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) |
Parse the JSON file and populate the json_value tree.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | p | output structure |
|
character(kind=CK,len=*), | intent(in) | :: | str | string with JSON data |
Parse the JSON string and populate the json_value tree.
Convert a 'DEFAULT' kind character input to 'ISO_10646' kind and return it
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(kind=CDK,len=*), | intent(in) | :: | str |
Convert string to unicode (CDK to CK).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(kind=CDK,len=*), | intent(in), | dimension(:) | :: | str |
Convert array of strings to unicode (CDK to CK).
Throw an exception.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(kind=CK,len=*), | intent(in) | :: | msg |
Throw an exception in the JSON module. This routine sets the error flag, and prevents any subsequent routine from doing anything, until json_clear_exceptions is called.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | intent(in), | pointer | :: | element | ||
integer(kind=IK), | intent(in) | :: | i | |||
integer(kind=IK), | intent(in) | :: | count |
Array element callback function. Used by json_get_array
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | intent(in), | pointer | :: | p | ||
logical(kind=LK), | intent(out) | :: | finished |
Callback function used by json_traverse
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
type(json_value), | private, | pointer | :: | previous | => | null() | previous item in the list |
type(json_value), | private, | pointer | :: | next | => | null() | next item in the list |
type(json_value), | private, | pointer | :: | parent | => | null() | parent item of this |
type(json_value), | private, | pointer | :: | children | => | null() | first child item of this |
type(json_value), | private, | pointer | :: | tail | => | null() | last child item of this |
character(kind=CK,len=:), | private, | allocatable | :: | name | variable name |
||
real(kind=RK), | private, | allocatable | :: | dbl_value | real data for this variable |
||
logical(kind=LK), | private, | allocatable | :: | log_value | logical data for this variable |
||
character(kind=CK,len=:), | private, | allocatable | :: | str_value | string data for this variable |
||
integer(kind=IK), | private, | allocatable | :: | int_value | integer data for this variable |
||
integer(kind=IK), | private | :: | var_type | = | json_unknown | variable type |
|
integer(kind=IK), | private | :: | n_children | = | 0 | number of children |
Type used to construct the linked-list JSON structure. Normally, this should always be a pointer variable.
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
type(json_value), | private, | pointer | :: | p | => | null() | the JSON structure read from the file |
Structure constructor to initialize a json_file object with an existing json_value object
private function initialize_json_file(p) | Cast a json_value object as a json_file object |
procedure, public :: load_file => json_file_load | |
generic, public :: load_from_string => json_file_load_from_string | |
procedure, public :: destroy => json_file_destroy | |
procedure, public :: move => json_file_move_pointer | |
generic, public :: info => json_file_variable_info | |
procedure, public :: print_to_string => json_file_print_to_string | |
generic, public :: print_file => json_file_print_to_console, json_file_print_1, json_file_print_2 | |
generic, public :: get => json_file_get_object, json_file_get_integer, json_file_get_double, json_file_get_logical, json_file_get_string, json_file_get_integer_vec, json_file_get_double_vec, json_file_get_logical_vec, json_file_get_string_vec, json_file_get_root | |
generic, public :: update => json_file_update_integer, json_file_update_logical, json_file_update_real, json_file_update_string | |
procedure, public :: json_file_load_from_string | |
procedure, public :: json_file_variable_info | |
procedure, public :: json_file_get_object | |
procedure, public :: json_file_get_integer | |
procedure, public :: json_file_get_double | |
procedure, public :: json_file_get_logical | |
procedure, public :: json_file_get_string | |
procedure, public :: json_file_get_integer_vec | |
procedure, public :: json_file_get_double_vec | |
procedure, public :: json_file_get_logical_vec | |
procedure, public :: json_file_get_string_vec | |
procedure, public :: json_file_get_root | |
procedure, public :: json_file_update_integer | |
procedure, public :: json_file_update_logical | |
procedure, public :: json_file_update_real | |
procedure, public :: json_file_update_string | |
procedure, public :: json_file_print_to_console | |
procedure, public :: json_file_print_1 | |
procedure, public :: json_file_print_2 |
The json_file is the main public class that is used to open a file and get data from it.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | intent(in), | optional | pointer | :: | p |
|
Cast a json_value object as a json_file object
Logical function to indicate if an exception has been thrown.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | intent(in), | pointer | :: | me |
number of children
Count the number of children.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(kind=CK,len=*), | intent(in) | :: | str |
Convert a string into an integer.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(kind=CK,len=*), | intent(in) | :: | str |
Convert a string into a double.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
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(out) | :: | eof | true if the end of the file has been reached. |
||
logical(kind=LK), | intent(in), | optional | :: | skip_ws | to ignore whitespace. |
the popped character.
Get the next character from the file (or string).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(kind=CK,len=*), | intent(in) | :: | str | the string to check. |
is str a value 4-digit hex string
Returns true if the string is a valid 4-digit hex string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(kind=CDK,len=*), | intent(in) | :: | str |
Convert string to unicode (CDK to CK).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(kind=CDK,len=*), | intent(in), | dimension(:) | :: | str |
Convert array of strings to unicode (CDK to CK).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(kind=CK,len=*), | intent(in) | :: | ucs4_str | |||
character(kind=CDK,len=*), | intent(in) | :: | def_str |
CK//CDK operator.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(kind=CDK,len=*), | intent(in) | :: | def_str | |||
character(kind=CK,len=*), | intent(in) | :: | ucs4_str |
CDK//CK operator.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(kind=CK,len=*), | intent(in) | :: | ucs4_str | |||
character(kind=CDK,len=*), | intent(in) | :: | def_str |
CK==CDK operator.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(kind=CDK,len=*), | intent(in) | :: | def_str | |||
character(kind=CK,len=*), | intent(in) | :: | ucs4_str |
CDK==CK operator.
Type | Intent | Optional | 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) |
Create a deep copy of a json_value linked-list structure.
Type | Intent | Optional | 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 |
type(json_value), | , | optional | pointer | :: | next | to%next |
type(json_value), | , | optional | pointer | :: | children | to%children |
logical | , | optional | :: | tail | if "to" is the tail of its parent's children |
Recursive deep copy function called by json_clone.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | intent(inout) | :: | d |
Destroy the data within a json_value, and rest type to json_unknown
.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(json_file), | intent(inout) | :: | to | |||
class(json_file), | intent(inout) | :: | from |
Move the json_value pointer from one json_file to another. The "from" pointer is then nullified, but not destroyed.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(json_file), | intent(inout) | :: | me | |||
character(kind=CDK,len=*), | intent(in) | :: | filename | the filename to open |
||
integer(kind=IK), | intent(in), | optional | :: | unit | the unit number to use (if not present, a newunit is used) |
Load the JSON data from a file.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(json_file), | intent(inout) | :: | me | |||
character(kind=CK,len=*), | intent(in) | :: | str | string to load JSON data from |
Load the JSON data from a string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(json_file), | intent(inout) | :: | me | |||
character(kind=CDK,len=*), | intent(in) | :: | str |
Alternate version of json_file_load_from_string, where "str" is kind=CDK.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(json_file), | intent(inout) | :: | me |
Print the JSON file to the console.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(json_file), | intent(inout) | :: | me | |||
integer(kind=IK), | intent(in) | :: | iunit | file unit number (must not be -1) |
Prints the JSON file to the specified file unit number.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(json_file), | intent(inout) | :: | me | |||
character(kind=CDK,len=*), | intent(in) | :: | filename | filename to print to |
Print the JSON structure to the specified filename. The file is opened, printed, and then closed.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(json_file), | intent(inout) | :: | me | |||
character(kind=CK,len=:), | intent(out), | allocatable | :: | str | string to print JSON data to |
Print the JSON file to a string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(json_file), | intent(inout) | :: | me | |||
character(kind=CK,len=*), | intent(in) | :: | path | path to the variable |
||
logical(kind=LK), | intent(out) | :: | found | the variable exists in the structure |
||
integer(kind=IK), | intent(out) | :: | var_type | variable type |
||
integer(kind=IK), | intent(out) | :: | n_children | number of children |
Returns information about a variable in a json_file.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(json_file), | intent(inout) | :: | me | |||
character(kind=CDK,len=*), | intent(in) | :: | path | |||
logical(kind=LK), | intent(out) | :: | found | |||
integer(kind=IK), | intent(out) | :: | var_type | |||
integer(kind=IK), | intent(out) | :: | n_children |
Alternate version of json_file_variable_info, where "path" is kind=CDK.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
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 |
Returns information about a json_value.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(json_file), | intent(inout) | :: | me | |||
character(kind=CK,len=*), | intent(in) | :: | path | the path to the variable |
||
type(json_value), | intent(out), | pointer | :: | p | pointer to the variable |
|
logical(kind=LK), | intent(out), | optional | :: | found | if it was really found |
Get a json_value pointer to an object from a JSON file.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(json_file), | intent(inout) | :: | me | |||
type(json_value), | intent(out), | pointer | :: | p | pointer to the variable |
Get a json_value pointer to the JSON file root.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(json_file), | intent(inout) | :: | me | |||
character(kind=CDK,len=*), | intent(in) | :: | path | |||
type(json_value), | intent(out), | pointer | :: | p | ||
logical(kind=LK), | intent(out), | optional | :: | found |
Alternate version of json_file_get_object, where "path" is kind=CDK.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(json_file), | intent(inout) | :: | me | |||
character(kind=CK,len=*), | intent(in) | :: | path | the path to the variable |
||
integer(kind=IK), | intent(out) | :: | val | value |
||
logical(kind=LK), | intent(out), | optional | :: | found | if it was really found |
Get an integer value from a JSON file.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(json_file), | intent(inout) | :: | me | |||
character(kind=CDK,len=*), | intent(in) | :: | path | |||
integer(kind=IK), | intent(out) | :: | val | |||
logical(kind=LK), | intent(out), | optional | :: | found |
Alternate version of json_file_get_integer, where "path" is kind=CDK.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(json_file), | intent(inout) | :: | me | |||
character(kind=CK,len=*), | intent(in) | :: | path | the path to the variable |
||
integer(kind=IK), | intent(out), | dimension(:), allocatable | :: | vec | the value vector |
|
logical(kind=LK), | intent(out), | optional | :: | found | if it was really found |
Get an integer vector from a JSON file.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(json_file), | intent(inout) | :: | me | |||
character(kind=CDK,len=*), | intent(in) | :: | path | |||
integer(kind=IK), | intent(out), | dimension(:), allocatable | :: | vec | ||
logical(kind=LK), | intent(out), | optional | :: | found |
Alternate version of json_file_get_integer_vec, where "path" is kind=CDK.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(json_file), | intent(inout) | :: | me | |||
character(kind=CK,len=*), | intent(in) | :: | path | |||
real(kind=RK), | intent(out) | :: | val | |||
logical(kind=LK), | intent(out), | optional | :: | found |
Get a real(RK) variable value from a JSON file.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(json_file), | intent(inout) | :: | me | |||
character(kind=CDK,len=*), | intent(in) | :: | path | |||
real(kind=RK), | intent(out) | :: | val | |||
logical(kind=LK), | intent(out), | optional | :: | found |
Alternate version of json_file_get_double, where "path" is kind=CDK.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(json_file), | intent(inout) | :: | me | |||
character(kind=CK,len=*), | intent(in) | :: | path | |||
real(kind=RK), | intent(out), | dimension(:), allocatable | :: | vec | ||
logical(kind=LK), | intent(out), | optional | :: | found |
Get a real(RK) vector from a JSON file.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(json_file), | intent(inout) | :: | me | |||
character(kind=CDK,len=*), | intent(in) | :: | path | |||
real(kind=RK), | intent(out), | dimension(:), allocatable | :: | vec | ||
logical(kind=LK), | intent(out), | optional | :: | found |
Alternate version of json_file_get_double_vec, where "path" is kind=CDK.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(json_file), | intent(inout) | :: | me | |||
character(kind=CK,len=*), | intent(in) | :: | path | |||
logical(kind=LK), | intent(out) | :: | val | |||
logical(kind=LK), | intent(out), | optional | :: | found |
Get a logical(LK) value from a JSON file.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(json_file), | intent(inout) | :: | me | |||
character(kind=CDK,len=*), | intent(in) | :: | path | |||
logical(kind=LK), | intent(out) | :: | val | |||
logical(kind=LK), | intent(out), | optional | :: | found |
Alternate version of json_file_get_logical, where "path" is kind=CDK.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(json_file), | intent(inout) | :: | me | |||
character(kind=CK,len=*), | intent(in) | :: | path | |||
logical(kind=LK), | intent(out), | dimension(:), allocatable | :: | vec | ||
logical(kind=LK), | intent(out), | optional | :: | found |
Get a logical(LK) vector from a JSON file.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(json_file), | intent(inout) | :: | me | |||
character(kind=CDK,len=*), | intent(in) | :: | path | |||
logical(kind=LK), | intent(out), | dimension(:), allocatable | :: | vec | ||
logical(kind=LK), | intent(out), | optional | :: | found |
Alternate version of json_file_get_logical_vec, where "path" is kind=CDK.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(json_file), | intent(inout) | :: | me | |||
character(kind=CK,len=*), | intent(in) | :: | path | |||
character(kind=CK,len=:), | intent(out), | allocatable | :: | val | ||
logical(kind=LK), | intent(out), | optional | :: | found |
Get a character string from a json file. The output val is an allocatable character string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(json_file), | intent(inout) | :: | me | |||
character(kind=CDK,len=*), | intent(in) | :: | path | |||
character(kind=CK,len=:), | intent(out), | allocatable | :: | val | ||
logical(kind=LK), | intent(out), | optional | :: | found |
Alternate version of json_file_get_string, where "path" is kind=CDK.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(json_file), | intent(inout) | :: | me | |||
character(kind=CK,len=*), | intent(in) | :: | path | |||
character(kind=CK,len=*), | intent(out), | dimension(:), allocatable | :: | vec | ||
logical(kind=LK), | intent(out), | optional | :: | found |
Get a string vector from a JSON file.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(json_file), | intent(inout) | :: | me | |||
character(kind=CDK,len=*), | intent(in) | :: | path | |||
character(kind=CK,len=*), | intent(out), | dimension(:), allocatable | :: | vec | ||
logical(kind=LK), | intent(out), | optional | :: | found |
Alternate version of json_file_get_string_vec, where "path" is kind=CDK.
Type | Intent | Optional | 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=len=*,CDK), | intent(in), | optional | :: | real_format | exponential (default), scientific, engineering or general |
Initialize the JSON-Fortran module. The routine must be called before any of the routines are used. It can also be called after using the module and encountering exceptions.
Clear exceptions in the JSON module.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(kind=CK,len=*), | intent(in) | :: | msg |
Throw an exception in the JSON module. This routine sets the error flag, and prevents any subsequent routine from doing anything, until json_clear_exceptions is called.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(kind=CDK,len=*), | intent(in) | :: | msg |
Alternate version of json_throw_exception, where "msg" is kind=CDK.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
logical(kind=LK), | intent(out) | :: | status_ok | true if there were no errors |
||
character(kind=CK,len=:), | intent(out), | allocatable | :: | error_msg | the error message (if there were errors) |
Retrieve error code from the module. This should be called after json_parse to check for errors. If an error is thrown, before using the module again, json_initialize should be called to clean up before it is used again.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | p |
Allocate a json_value pointer variable. This should be called before adding data to it.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | me | ||
logical(kind=LK), | intent(in), | optional | :: | destroy_next | if true, then me%next is also destroyed (default is true) |
Destroy a json_value linked-list structure.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | me | ||
logical(kind=LK), | intent(in), | optional | :: | destroy | If destroy is not present, it is also destroyed. If destroy is present and true, it is destroyed. If destroy is present and false, it is not destroyed. |
Remove a json_value (and all its children) from a linked-list structure, preserving the rest of the structure.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | p | ||
character(kind=CK,len=*), | intent(in) | :: | name |
Given the path string, remove the variable from the json_value structure, if it exists.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | p | ||
character(kind=CDK,len=*), | intent(in) | :: | name |
Alternate version of json_value_remove_if_present, where "name" is kind=CDK.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(json_file), | intent(inout) | :: | me | |||
character(kind=CK,len=*), | intent(in) | :: | name | |||
integer(kind=IK), | intent(in) | :: | val | |||
logical(kind=LK), | intent(out) | :: | found |
Given the path string, if the variable is present in the file, and is a scalar, then update its value. If it is not present, then create it and set its value.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(json_file), | intent(inout) | :: | me | |||
character(kind=CDK,len=*), | intent(in) | :: | name | |||
integer(kind=IK), | intent(in) | :: | val | |||
logical(kind=LK), | intent(out) | :: | found |
Alternate version of json_file_update_integer, where "name" is kind=CDK.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(json_file), | intent(inout) | :: | me | |||
character(kind=CK,len=*), | intent(in) | :: | name | |||
logical(kind=LK), | intent(in) | :: | val | |||
logical(kind=LK), | intent(out) | :: | found |
Given the path string, if the variable is present in the file, and is a scalar, then update its value. If it is not present, then create it and set its value.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(json_file), | intent(inout) | :: | me | |||
character(kind=CDK,len=*), | intent(in) | :: | name | |||
logical(kind=LK), | intent(in) | :: | val | |||
logical(kind=LK), | intent(out) | :: | found |
Alternate version of json_file_update_logical, where "name" is kind=CDK.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(json_file), | intent(inout) | :: | me | |||
character(kind=CK,len=*), | intent(in) | :: | name | |||
real(kind=RK), | intent(in) | :: | val | |||
logical(kind=LK), | intent(out) | :: | found |
Given the path string, if the variable is present in the file, and is a scalar, then update its value. If it is not present, then create it and set its value.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(json_file), | intent(inout) | :: | me | |||
character(kind=CDK,len=*), | intent(in) | :: | name | |||
real(kind=RK), | intent(in) | :: | val | |||
logical(kind=LK), | intent(out) | :: | found |
Alternate version of json_file_update_real, where "name" is kind=CDK.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(json_file), | intent(inout) | :: | me | |||
character(kind=CK,len=*), | intent(in) | :: | name | |||
character(kind=CK,len=*), | intent(in) | :: | val | |||
logical(kind=LK), | intent(out) | :: | found |
Given the path string, if the variable is present in the file, and is a scalar, then update its value. If it is not present, then create it and set its value.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(json_file), | intent(inout) | :: | me | |||
character(kind=CDK,len=*), | intent(in) | :: | name | |||
character(kind=CDK,len=*), | intent(in) | :: | val | |||
logical(kind=LK), | intent(out) | :: | found |
Alternate version of json_file_update_string, where "name" and "val" are kind=CDK.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(json_file), | intent(inout) | :: | me | |||
character(kind=CDK,len=*), | intent(in) | :: | name | |||
character(kind=CK,len=*), | intent(in) | :: | val | |||
logical(kind=LK), | intent(out) | :: | found |
Alternate version of json_file_update_string, where "name" is kind=CDK.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(json_file), | intent(inout) | :: | me | |||
character(kind=CK,len=*), | intent(in) | :: | name | |||
character(kind=CDK,len=*), | intent(in) | :: | val | |||
logical(kind=LK), | intent(out) | :: | found |
Alternate version of json_file_update_string, where "val" is kind=CDK.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | p | ||
character(kind=CK,len=*), | intent(in) | :: | name | |||
logical(kind=LK), | intent(in) | :: | val | |||
logical(kind=LK), | intent(out) | :: | found |
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.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | p | ||
character(kind=CDK,len=*), | intent(in) | :: | name | |||
logical(kind=LK), | intent(in) | :: | val | |||
logical(kind=LK), | intent(out) | :: | found |
Alternate version of json_update_logical, where "name" is kind=CDK.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | p | ||
character(kind=CK,len=*), | intent(in) | :: | name | |||
real(kind=RK), | intent(in) | :: | val | |||
logical(kind=LK), | intent(out) | :: | found |
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.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | p | ||
character(kind=CDK,len=*), | intent(in) | :: | name | |||
real(kind=RK), | intent(in) | :: | val | |||
logical(kind=LK), | intent(out) | :: | found |
Alternate version of json_update_double, where "name" is kind=CDK.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | p | ||
character(kind=CK,len=*), | intent(in) | :: | name | |||
integer(kind=IK), | intent(in) | :: | val | |||
logical(kind=LK), | intent(out) | :: | found |
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.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | p | ||
character(kind=CDK,len=*), | intent(in) | :: | name | |||
integer(kind=IK), | intent(in) | :: | val | |||
logical(kind=LK), | intent(out) | :: | found |
Alternate version of json_update_integer, where "name" is kind=CDK.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | p | ||
character(kind=CK,len=*), | intent(in) | :: | name | |||
character(kind=CK,len=*), | intent(in) | :: | val | |||
logical(kind=LK), | intent(out) | :: | found |
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.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | p | ||
character(kind=CDK,len=*), | intent(in) | :: | name | |||
character(kind=CDK,len=*), | intent(in) | :: | val | |||
logical(kind=LK), | intent(out) | :: | found |
Alternate version of json_update_string, where "name" and "value" are kind=CDK.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | p | ||
character(kind=CDK,len=*), | intent(in) | :: | name | |||
character(kind=CK,len=*), | intent(in) | :: | val | |||
logical(kind=LK), | intent(out) | :: | found |
Alternate version of json_update_string, where "name" is kind=CDK.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | p | ||
character(kind=CK,len=*), | intent(in) | :: | name | |||
character(kind=CDK,len=*), | intent(in) | :: | val | |||
logical(kind=LK), | intent(out) | :: | found |
Alternate version of json_update_string, where "val" is kind=CDK.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | me | ||
type(json_value), | , | pointer | :: | member | the child member to add |
Adds "member" as a child of "me".
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | me | ||
character(kind=CK,len=*), | intent(in) | :: | name | variable name |
||
real(kind=RK), | intent(in) | :: | val | real value |
Add a real value child to the json_value variable
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | me | ||
character(kind=CDK,len=*), | intent(in) | :: | name | variable name |
||
real(kind=RK), | intent(in) | :: | val | real value |
Alternate version of json_value_add_double where "name" is kind=CDK.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | me | ||
character(kind=CK,len=*), | intent(in) | :: | name | |||
real(kind=RK), | intent(in), | dimension(:) | :: | val |
Add a real vector to the structure.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | me | ||
character(kind=CDK,len=*), | intent(in) | :: | name | |||
real(kind=RK), | intent(in), | dimension(:) | :: | val |
Alternate version of json_value_add_double_vec where "name" is kind=CDK.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | me | ||
character(kind=CK,len=*), | intent(in) | :: | name | |||
integer(kind=IK), | intent(in) | :: | val |
Add an integer value child to the json_value variable
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | me | ||
character(kind=CDK,len=*), | intent(in) | :: | name | name of the variable |
||
integer(kind=IK), | intent(in) | :: | val | value |
Alternate version of json_value_add_integer where "name" is kind=CDK.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | me | ||
character(kind=CK,len=*), | intent(in) | :: | name | name of the variable |
||
integer(kind=IK), | intent(in), | dimension(:) | :: | val | value |
Add an integer vector to the structure.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | me | ||
character(kind=CDK,len=*), | intent(in) | :: | name | name of the variable |
||
integer(kind=IK), | intent(in), | dimension(:) | :: | val | value |
Alternate version of json_value_add_integer_vec where "name" is kind=CDK.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | me | ||
character(kind=CK,len=*), | intent(in) | :: | name | name of the variable |
||
logical(kind=LK), | intent(in) | :: | val | value |
Add a logical value child to the json_value variable
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | me | ||
character(kind=CDK,len=*), | intent(in) | :: | name | name of the variable |
||
logical(kind=LK), | intent(in) | :: | val | value |
Alternate version of json_value_add_logical where "name" is kind=CDK.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | me | ||
character(kind=CK,len=*), | intent(in) | :: | name | name of the vector |
||
logical(kind=LK), | intent(in), | dimension(:) | :: | val | value |
Add a logical vector to the structure.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | me | ||
character(kind=CDK,len=*), | intent(in) | :: | name | name of the variable |
||
logical(kind=LK), | intent(in), | dimension(:) | :: | val | value |
Alternate version of json_value_add_logical_vec where "name" is kind=CDK.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | me | ||
character(kind=CK,len=*), | intent(in) | :: | name | name of the variable |
||
character(kind=CK,len=*), | intent(in) | :: | val | value |
Add a character string child to the json_value variable.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | me | ||
character(kind=CDK,len=*), | intent(in) | :: | name | name of the variable |
||
character(kind=CDK,len=*), | intent(in) | :: | val | value |
Alternate version of json_value_add_string where "name" and "val" are kind=CDK.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | me | ||
character(kind=CDK,len=*), | intent(in) | :: | name | name of the variable |
||
character(kind=CK,len=*), | intent(in) | :: | val | value |
Alternate version of json_value_add_string where "name" is kind=CDK.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | me | ||
character(kind=CK,len=*), | intent(in) | :: | name | name of the variable |
||
character(kind=CDK,len=*), | intent(in) | :: | val | value |
Alternate version of json_value_add_string where "val" is kind=CDK.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(kind=CK,len=*), | intent(in) | :: | str_in | |||
character(kind=CK,len=:), | intent(out), | allocatable | :: | str_out |
Add the escape characters to a string for adding to JSON.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | me | ||
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 |
Add an array of character strings to the structure.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | me | ||
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 |
Alternate version of json_value_add_string_vec where "name" and "val" are kind=CDK.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | me | ||
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 |
Alternate version of json_value_add_string_vec where "name" is kind=CDK.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | me | ||
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 |
Alternate version of json_value_add_string_vec where "val" is kind=CDK.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | intent(in), | pointer | :: | me | JSON object |
|
type(json_value), | intent(out), | pointer | :: | p | pointer to parent |
Returns a pointer to the parent of a json_value. If there is no parent, then a null() pointer is returned.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | intent(in), | pointer | :: | me | JSON object |
|
type(json_value), | intent(out), | pointer | :: | p | pointer to next |
Returns a pointer to the next of a json_value. If there is no next, then a null() pointer is returned.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | intent(in), | pointer | :: | me | JSON object |
|
type(json_value), | intent(out), | pointer | :: | p | pointer to previous |
Returns a pointer to the previous of a json_value. If there is no previous, then a null() pointer is returned.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | intent(in), | pointer | :: | me | JSON object |
|
type(json_value), | intent(out), | pointer | :: | p | pointer to tail |
Returns a pointer to the tail of a json_value. If there is no tail, then a null() pointer is returned.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | intent(in), | pointer | :: | me | object or array JSON data |
|
integer(kind=IK), | intent(in) | :: | idx | index of the child |
||
type(json_value), | , | pointer | :: | p | pointer to the child |
Returns a child in the object or array given the index.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | intent(in), | pointer | :: | me | ||
character(kind=CK,len=*), | intent(in) | :: | name | the name of a child of "me" |
||
type(json_value), | , | pointer | :: | p | pointer to the child |
Returns a child in the object or array given the name string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | intent(in), | pointer | :: | me | ||
character(kind=CDK,len=*), | intent(in) | :: | name | |||
type(json_value), | , | pointer | :: | p |
Alternate version of json_value_get_by_name_chars where "name" is kind=CDK.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | intent(in), | pointer | :: | me | ||
character(kind=CK,len=:), | intent(out), | allocatable | :: | str | prints structure to this string |
Print the json_value structure to an allocatable string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | intent(in), | pointer | :: | me | ||
integer(kind=IK), | intent(in) | :: | iunit | the file unit (the file must already have been opened, can't be -1). |
Print the json_value structure to a file.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | intent(in), | pointer | :: | me | ||
character(kind=CDK,len=*), | intent(in) | :: | filename | the filename to print to (should not already be open) |
Print the json_value structure to a file.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | intent(in), | pointer | :: | me | ||
integer(kind=IK), | intent(in) | :: | iunit | file unit to write to (6=console) |
||
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 |
Print the JSON structure to a string or a file.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | intent(in), | pointer | :: | me | ||
character(kind=CK,len=*), | intent(in) | :: | path | |||
type(json_value), | intent(out), | pointer | :: | p | ||
logical(kind=LK), | intent(out), | optional | :: | found | true if it was found |
Returns the json_value pointer given the path string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
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 |
Alternate version of json_get_by_path where "path" is kind=CDK.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | intent(in), | pointer | :: | me | ||
integer(kind=IK), | intent(out) | :: | value |
Get an integer value from a json_value.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
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 |
Get an integer value from a json_value, given the path string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
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 |
Alternate version of json_get_integer_with_path, where "path" is kind=CDK.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | me | ||
integer(kind=IK), | intent(out), | dimension(:), allocatable | :: | vec |
Get an integer vector from a json_value.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | me | ||
character(kind=CK,len=*), | intent(in) | :: | path | |||
integer(kind=IK), | intent(out), | dimension(:), allocatable | :: | vec | ||
logical(kind=LK), | intent(out), | optional | :: | found |
Get an integer vector from a json_value, given the path string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
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 |
Alternate version of json_get_integer_vec_with_path, where "path" is kind=CDK
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | me | ||
real(kind=RK), | intent(out) | :: | value |
Get a double value from a json_value.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
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 |
Get a double value from a json_value, given the path.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
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 |
Alternate version of json_get_double_with_path, where "path" is kind=CDK
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | me | ||
real(kind=RK), | intent(out), | dimension(:), allocatable | :: | vec |
Get a double vector from a json_value.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | me | ||
character(kind=CK,len=*), | intent(in) | :: | path | |||
real(kind=RK), | intent(out), | dimension(:), allocatable | :: | vec | ||
logical(kind=LK), | intent(out), | optional | :: | found |
Get a double vector from a json_value, given the path.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
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 |
Alternate version of json_get_double_vec_with_path, where "path" is kind=CDK
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | intent(in), | pointer | :: | me | ||
logical(kind=LK) | :: | value |
Get a logical value from a json_value.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | intent(in), | pointer | :: | me | ||
character(kind=CK,len=*), | intent(in) | :: | path | |||
logical(kind=LK) | :: | value | ||||
logical(kind=LK), | intent(out), | optional | :: | found |
Get a logical value from a json_value, given the path.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | intent(in), | pointer | :: | me | ||
character(kind=CDK,len=*), | intent(in) | :: | path | |||
logical(kind=LK) | :: | value | ||||
logical(kind=LK), | intent(out), | optional | :: | found |
Alternate version of json_get_logical_with_path, where "path" is kind=CDK
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | intent(in), | pointer | :: | me | ||
logical(kind=LK), | intent(out), | dimension(:), allocatable | :: | vec |
Get a logical vector from json_value.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
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 |
Get a logical vector from a json_value, given the path.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
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 |
Alternate version of json_get_logical_vec_with_path, where "path" is kind=CDK
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | intent(in), | pointer | :: | me | ||
character(kind=CK,len=:), | intent(out), | allocatable | :: | value |
Get a character string from a json_value.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(kind=CK,len=*), | intent(in) | :: | str_in | string as stored in a json_value |
||
character(kind=CK,len=:), | intent(out), | allocatable | :: | str_out | decoded string |
Remove the escape characters from a JSON string and return it.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
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 |
Get a character string from a json_value, given the path.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
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 |
Alternate version of json_get_string_with_path, where "path" is kind=CDK
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | intent(in), | pointer | :: | me | ||
character(kind=CK,len=*), | intent(out), | dimension(:), allocatable | :: | vec |
Get a string vector from a json_file.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
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 |
Get a string vector from a json_file, given the path.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
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 |
Alternate version of json_get_string_vec_with_path, where "path" is kind=CDK
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | intent(in), | pointer | :: | me | ||
procedure(array_callback_func) | :: | array_callback |
This routine calls the user-supplied array_callback_func subroutine for each element in the array.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | intent(in), | pointer | :: | me | ||
procedure(traverse_callback_func) | :: | traverse_callback |
Traverse a JSON structure. This routine calls the user-specified traverse_callback_func for each element of the structure.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | intent(in), | pointer | :: | me | ||
character(kind=CK,len=*), | intent(in) | :: | path | |||
procedure(array_callback_func) | :: | array_callback | ||||
logical(kind=LK), | intent(out), | optional | :: | found |
This routine calls the user-supplied array_callback subroutine for each element in the array (specified by the path).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | intent(in), | pointer | :: | me | ||
character(kind=CDK,len=*), | intent(in) | :: | path | |||
procedure(array_callback_func) | :: | array_callback | ||||
logical(kind=LK), | intent(out), | optional | :: | found |
Alternate version of json_get_array_with_path, where "path" is kind=CDK
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
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) |
Parse the JSON file and populate the json_value tree.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | p | output structure |
|
character(kind=CK,len=*), | intent(in) | :: | str | string with JSON data |
Parse the JSON string and populate the json_value tree.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | p | output structure |
|
character(kind=CDK,len=*), | intent(in) | :: | str | string with JSON data |
Alternate version of json_parse_string, where "str" is kind=CDK.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=IK), | intent(in) | :: | iunit | file unit number |
||
character(kind=CK,len=*), | intent(in) | :: | str | string with JSON data |
Generate a warning message if there was an error parsing a JSON file or string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=IK), | intent(in) | :: | iunit | file unit number |
||
character(kind=CK,len=:), | intent(out), | allocatable | :: | line | current line |
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).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=IK), | intent(in) | :: | iunit | file unit number |
||
character(kind=CK,len=:), | intent(out), | allocatable | :: | line | current line |
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).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
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 |
Core parsing routine.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | me | ||
logical(kind=LK), | intent(in) | :: | val | variable value |
||
character(kind=CK,len=*), | intent(in) | :: | name | variable name |
Allocate a json_value pointer and make it a logical(LK) variable. The pointer should not already be allocated.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | me | ||
logical(kind=LK), | intent(in) | :: | val | |||
character(kind=CDK,len=*), | intent(in) | :: | name |
Wrapper for json_value_create_logical so json_create_logical can be called with name of character kind 'DEFAULT' or 'ISO_10646'
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | me | ||
integer(kind=IK), | intent(in) | :: | val | |||
character(kind=CK,len=*), | intent(in) | :: | name |
Allocate a json_value pointer and make it an integer(IK) variable. The pointer should not already be allocated.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | me | ||
integer(kind=IK), | intent(in) | :: | val | |||
character(kind=CDK,len=*), | intent(in) | :: | name |
A wrapper procedure for json_value_create_integer so that json_create_integer may be called with either a 'DEFAULT' or 'ISO_10646' character kind 'name' actual argument.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | me | ||
real(kind=RK), | intent(in) | :: | val | |||
character(kind=CK,len=*), | intent(in) | :: | name |
Allocate a json_value pointer and make it a real(RK) variable. The pointer should not already be allocated.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | me | ||
real(kind=RK), | intent(in) | :: | val | |||
character(kind=CDK,len=*), | intent(in) | :: | name |
A wrapper for json_value_create_double so that json_create_double may be called with an actual argument corresponding to the dummy argument, 'name' that may be of 'DEFAULT' or 'ISO_10646' character kind.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | me | ||
character(kind=CK,len=*), | intent(in) | :: | val | |||
character(kind=CK,len=*), | intent(in) | :: | name |
Allocate a json_value pointer and make it a string variable. The pointer should not already be allocated.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | me | ||
character(kind=CDK,len=*), | intent(in) | :: | val | |||
character(kind=CDK,len=*), | intent(in) | :: | name |
Wrap json_value_create_string so that json_create_string may be called with actual character string arguments for 'name' and 'val' that are BOTH of 'DEFAULT' or 'ISO_10646' character kind.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | me | ||
character(kind=CK,len=*), | intent(in) | :: | name |
Allocate a json_value pointer and make it a null variable. The pointer should not already be allocated.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | me | ||
character(kind=CDK,len=*), | intent(in) | :: | name |
Wrap json_value_create_null so that json_create_null may be called with an actual argument corresponding to the dummy argument 'name' that is either of 'DEFAULT' or 'ISO_10646' character kind.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | me | ||
character(kind=CK,len=*), | intent(in) | :: | name |
Allocate a json_value pointer and make it an object variable. The pointer should not already be allocated.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | me | ||
character(kind=CDK,len=*), | intent(in) | :: | name |
Wrap json_value_create_object so that json_create_object may be called with an actual argument corresponding to the dummy argument 'name' that is of either 'DEFAULT' or 'ISO_10646' character kind.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | me | ||
character(kind=CK,len=*), | intent(in) | :: | name |
Allocate a json_value pointer and make it an array variable. The pointer should not already be allocated.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | me | ||
character(kind=CDK,len=*), | intent(in) | :: | name |
A wrapper for json_value_create_array so that json_create_array may be called with an actual argument, corresponding to the dummy argument 'name', that is either of 'DEFAULT' or 'ISO_10646' character kind.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | intent(inout) | :: | me | |||
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. |
Change the json_value variable to a logical.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | intent(inout) | :: | me | |||
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. |
Change the json_value variable to an integer.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | intent(inout) | :: | me | |||
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. |
Change the json_value variable to a double.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | intent(inout) | :: | me | |||
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. |
Change the json_value variable to a string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | intent(inout) | :: | me | |||
character(kind=CK,len=*), | intent(in), | optional | :: | name | if the name is also to be changed. |
Change the json_value variable to a null.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | intent(inout) | :: | me | |||
character(kind=CK,len=*), | intent(in), | optional | :: | name | if the name is also to be changed. |
Change the json_value variable to an object.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | intent(inout) | :: | me | |||
character(kind=CK,len=*), | intent(in), | optional | :: | name | if the name is also to be changed. |
Change the json_value variable to an array.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
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 |
Core parsing routine.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
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 |
Core parsing routine.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
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 |
Parses a string while reading a JSON file.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
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. |
Core parsing routine.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
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 |
Read a numerical value from the file (or string). The routine will determine if it is an integer or a double, and allocate the type accordingly.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(kind=CK,len=1), | intent(in) | :: | c |
Core routine.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=IK), | intent(in) | :: | ival | integer value. |
||
character(kind=CK,len=*), | intent(out) | :: | str | ival converted to a string. |
Convert an integer to a string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=RK), | intent(in) | :: | rval | real value. |
||
character(kind=CK,len=*), | intent(out) | :: | str | rval converted to a string. |
Convert a real value to a string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(kind=CK,len=*), | intent(inout) | :: | str | string representation of a real number. |
Compact a string representing a real number, so that the same value is displayed with fewer characters.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in), | optional | :: | io_unit |
Print any error message, and then clear the exceptions.