The json_file
is the main public class that is
used to open a file and get data from it.
A json_file
contains only two items: an instance of a json_core,
which use used for all data manipulation, and a json_value,
which is used to construct the linked-list data structure.
Note that most methods in the json_file
class are simply wrappers
to the lower-level routines in the json_value_module.
program test use json_module implicit none type(json_file) :: json integer :: ival real(real64) :: rval character(len=:),allocatable :: cval logical :: found call json%initialize(compact_reals=.true.) call json%load_file(filename='myfile.json') call json%print_file() !print to the console call json%get('var.i',ival,found) call json%get('var.r(3)',rval,found) call json%get('var.c',cval,found) call json%destroy() end program test
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
type(json_core), | private | :: | core | The instance of the json_core factory used for this file. |
|||
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, and either the json_core settings or a json_core instance.
Cast a json_value object as a json_file object.
It also calls the initialize()
method.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | intent(in), | optional | pointer | :: | p |
|
logical(kind=LK), | intent(in), | optional | :: | verbose | mainly useful for debugging (default is false) |
|
logical(kind=LK), | intent(in), | optional | :: | compact_reals | to compact the real number strings for output (default is true) |
|
logical(kind=LK), | intent(in), | optional | :: | print_signs | always print numeric sign (default is false) |
|
character(kind=CDK,len=*), | intent(in), | optional | :: | real_format | Real number format: 'E' [default], '*', 'G', 'EN', or 'ES' |
|
integer(kind=IK), | intent(in), | optional | :: | spaces_per_tab | number of spaces per tab for indenting (default is 2) |
|
logical(kind=LK), | intent(in), | optional | :: | strict_type_checking | if true, no integer, double, or logical type
conversions are done for the |
|
logical(kind=LK), | intent(in), | optional | :: | trailing_spaces_significant | for name and path comparisons, is trailing space to be considered significant. (default is false) |
|
logical(kind=LK), | intent(in), | optional | :: | case_sensitive_keys | for name and path comparisons, are they case sensitive. (default is true) |
|
logical(kind=LK), | intent(in), | optional | :: | no_whitespace | if true, printing the JSON structure is done without adding any non-significant spaces or linebreaks (default is false) |
|
logical(kind=LK), | intent(in), | optional | :: | unescape_strings | If false, then the raw escaped string is returned from json_get_string and similar routines. If true [default], then the string is returned unescaped. |
Cast a json_value pointer and a json_core object as a json_file object.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | intent(in), | pointer | :: | json_value_object | ||
type(json_core), | intent(in) | :: | json_core_object |
Retrieve error status and message from the class.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(json_file), | intent(inout) | :: | me | |||
logical(kind=LK), | intent(out) | :: | status_ok | true if there were no errors |
||
character(kind=CK,len=:), | intent(out), | allocatable | :: | error_msg | the error message (if there were errors) |
Clear exceptions in the class.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(json_file), | intent(inout) | :: | me |
Destroy the json_value data in a json_file. This must be done when the variable is no longer needed, or will be reused to open a different file. Otherwise a memory leak will occur.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(json_file), | intent(inout) | :: | me | |||
logical, | intent(in), | optional | :: | destroy_core | to also destroy the json_core. default is to leave it as is. |
Check error status in the file.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(json_file), | intent(in) | :: | me |
will be true if there has been an error.
Get a json_value pointer to an object from a JSON file.
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 an integer value from a JSON file.
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 a real(RK) variable value from a JSON file.
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 logical(LK) value from a JSON file.
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 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=CK,len=*), | intent(in) | :: | path | |||
character(kind=CK,len=:), | intent(out), | allocatable | :: | val | ||
logical(kind=LK), | intent(out), | optional | :: | found |
Get an integer vector from a JSON file.
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 a real(RK) vector from a JSON file.
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 logical(LK) vector from a JSON file.
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 string vector from a JSON file.
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 json_value pointer to the JSON file root.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(json_file), | intent(inout) | :: | me | |||
type(json_value), | intent(out), | pointer | :: | p | pointer to the variable |
Get a copy of the json_core in this json_file.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(json_file), | intent(in) | :: | me | |||
type(json_core), | intent(out) | :: | core |
Returns information about a variable in a json_file.
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), | optional | :: | found | the variable exists in the structure |
|
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 |
Initialize the json_core for this json_file. This is just a wrapper for json_initialize.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(json_file), | intent(inout) | :: | me | |||
logical(kind=LK), | intent(in), | optional | :: | verbose | mainly useful for debugging (default is false) |
|
logical(kind=LK), | intent(in), | optional | :: | compact_reals | to compact the real number strings for output (default is true) |
|
logical(kind=LK), | intent(in), | optional | :: | print_signs | always print numeric sign (default is false) |
|
character(kind=CDK,len=*), | intent(in), | optional | :: | real_format | Real number format: 'E' [default], '*', 'G', 'EN', or 'ES' |
|
integer(kind=IK), | intent(in), | optional | :: | spaces_per_tab | number of spaces per tab for indenting (default is 2) |
|
logical(kind=LK), | intent(in), | optional | :: | strict_type_checking | if true, no integer, double, or logical type
conversions are done for the |
|
logical(kind=LK), | intent(in), | optional | :: | trailing_spaces_significant | for name and path comparisons, is trailing space to be considered significant. (default is false) |
|
logical(kind=LK), | intent(in), | optional | :: | case_sensitive_keys | for name and path comparisons, are they case sensitive. (default is true) |
|
logical(kind=LK), | intent(in), | optional | :: | no_whitespace | if true, printing the JSON structure is done without adding any non-significant spaces or linebreaks (default is false) |
|
logical(kind=LK), | intent(in), | optional | :: | unescape_strings | If false, then the raw escaped string is returned from json_get_string and similar routines. If true [default], then the string is returned unescaped. |
Set the json_core for this json_file.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(json_file), | intent(inout) | :: | me | |||
type(json_core), | intent(in) | :: | core |
Initialize the json_core for this json_file. This is just a wrapper for json_initialize.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(json_file), | intent(inout) | :: | me | |||
logical(kind=LK), | intent(in), | optional | :: | verbose | mainly useful for debugging (default is false) |
|
logical(kind=LK), | intent(in), | optional | :: | compact_reals | to compact the real number strings for output (default is true) |
|
logical(kind=LK), | intent(in), | optional | :: | print_signs | always print numeric sign (default is false) |
|
character(kind=CDK,len=*), | intent(in), | optional | :: | real_format | Real number format: 'E' [default], '*', 'G', 'EN', or 'ES' |
|
integer(kind=IK), | intent(in), | optional | :: | spaces_per_tab | number of spaces per tab for indenting (default is 2) |
|
logical(kind=LK), | intent(in), | optional | :: | strict_type_checking | if true, no integer, double, or logical type
conversions are done for the |
|
logical(kind=LK), | intent(in), | optional | :: | trailing_spaces_significant | for name and path comparisons, is trailing space to be considered significant. (default is false) |
|
logical(kind=LK), | intent(in), | optional | :: | case_sensitive_keys | for name and path comparisons, are they case sensitive. (default is true) |
|
logical(kind=LK), | intent(in), | optional | :: | no_whitespace | if true, printing the JSON structure is done without adding any non-significant spaces or linebreaks (default is false) |
|
logical(kind=LK), | intent(in), | optional | :: | unescape_strings | If false, then the raw escaped string is returned from json_get_string and similar routines. If true [default], then the string is returned unescaped. |
Get a real(RK) variable value from a JSON file.
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) vector from a JSON file.
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 an integer value from a JSON file.
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 vector from a JSON file.
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 a logical(LK) value from a JSON file.
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) vector from a JSON file.
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 json_value pointer to an object from a JSON file.
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 the JSON file root.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(json_file), | intent(inout) | :: | me | |||
type(json_value), | intent(out), | pointer | :: | p | pointer to the variable |
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=CK,len=*), | intent(in) | :: | path | |||
character(kind=CK,len=:), | intent(out), | allocatable | :: | val | ||
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=CK,len=*), | intent(in) | :: | path | |||
character(kind=CK,len=*), | intent(out), | dimension(:), allocatable | :: | vec | ||
logical(kind=LK), | intent(out), | optional | :: | found |
Load the JSON data from a string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(json_file), | intent(inout) | :: | me | |||
character(kind=CK,len=*), | intent(in) | :: | str | string to load JSON data from |
Prints the JSON file to the specified file unit number.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(json_file), | intent(inout) | :: | me | |||
integer(kind=IK), | intent(in) | :: | iunit | file unit number (must not be -1) |
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=CDK,len=*), | intent(in) | :: | filename | filename to print to |
Print the JSON file to the console.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(json_file), | intent(inout) | :: | me |
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=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=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=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=CK,len=*), | intent(in) | :: | name | |||
character(kind=CK,len=*), | intent(in) | :: | val | |||
logical(kind=LK), | intent(out) | :: | found |
Returns information about a variable in a json_file.
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), | optional | :: | found | the variable exists in the structure |
|
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 matrix information about a variable in a json_file.
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) | :: | is_matrix | true if it is a valid matrix |
||
logical(kind=LK), | intent(out), | optional | :: | found | true if it was found |
|
integer(kind=IK), | intent(out), | optional | :: | var_type | variable type of data in the matrix (if all elements have the same type) |
|
integer(kind=IK), | intent(out), | optional | :: | n_sets | number of data sets (i.e., matrix rows if using row-major order) |
|
integer(kind=IK), | intent(out), | optional | :: | set_size | size of each data set (i.e., matrix cols if using row-major order) |
|
character(kind=CK,len=:), | intent(out), | optional | allocatable | :: | name | variable name |
Load the JSON data from a file.
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 string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(json_file), | intent(inout) | :: | me | |||
character(kind=CK,len=*), | intent(in) | :: | str | string to load JSON data from |
Returns matrix information about a variable in a json_file.
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) | :: | is_matrix | true if it is a valid matrix |
||
logical(kind=LK), | intent(out), | optional | :: | found | true if it was found |
|
integer(kind=IK), | intent(out), | optional | :: | var_type | variable type of data in the matrix (if all elements have the same type) |
|
integer(kind=IK), | intent(out), | optional | :: | n_sets | number of data sets (i.e., matrix rows if using row-major order) |
|
integer(kind=IK), | intent(out), | optional | :: | set_size | size of each data set (i.e., matrix cols if using row-major order) |
|
character(kind=CK,len=:), | intent(out), | optional | allocatable | :: | name | variable name |
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) | :: | to | |||
class(json_file), | intent(inout) | :: | from |
This is a wrapper for json_print_error_message.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(json_file), | intent(inout) | :: | me | |||
integer, | intent(in), | optional | :: | io_unit |
Print the JSON file to the console.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(json_file), | intent(inout) | :: | me |
Prints the JSON file to the specified file unit number.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(json_file), | intent(inout) | :: | me | |||
integer(kind=IK), | intent(in) | :: | iunit | file unit number (must not be -1) |
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=CDK,len=*), | intent(in) | :: | filename | filename to print to |
Print the JSON file to a string.
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 |
Set the json_core for this json_file.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(json_file), | intent(inout) | :: | me | |||
type(json_core), | intent(in) | :: | core |
Traverse the JSON structure in the file. This routine calls the user-specified json_traverse_callback_func for each element of the structure.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(json_file), | intent(inout) | :: | me | |||
procedure(json_traverse_callback_func) | :: | traverse_callback |
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=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=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=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=CK,len=*), | intent(in) | :: | name | |||
character(kind=CK,len=*), | intent(in) | :: | val | |||
logical(kind=LK), | intent(out) | :: | found |
type,public :: json_file
private
type(json_core) :: core !! The instance of the [[json_core]] factory used for this file.
type(json_value),pointer :: p => null() !! the JSON structure read from the file
contains
generic,public :: initialize => initialize_json_core_in_file,&
set_json_core_in_file
procedure,public :: get_core => get_json_core_in_file
procedure,public :: load_file => json_file_load
generic,public :: load_from_string => MAYBEWRAP(json_file_load_from_string)
procedure,public :: destroy => json_file_destroy
procedure,public :: move => json_file_move_pointer
generic,public :: info => MAYBEWRAP(json_file_variable_info)
generic,public :: matrix_info => MAYBEWRAP(json_file_variable_matrix_info)
!error checking:
procedure,public :: failed => json_file_failed
procedure,public :: print_error_message => json_file_print_error_message
procedure,public :: check_for_errors => json_file_check_for_errors
procedure,public :: clear_exceptions => json_file_clear_exceptions
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 => MAYBEWRAP(json_file_get_object), &
MAYBEWRAP(json_file_get_integer), &
MAYBEWRAP(json_file_get_double), &
MAYBEWRAP(json_file_get_logical), &
MAYBEWRAP(json_file_get_string), &
MAYBEWRAP(json_file_get_integer_vec), &
MAYBEWRAP(json_file_get_double_vec), &
MAYBEWRAP(json_file_get_logical_vec), &
MAYBEWRAP(json_file_get_string_vec), &
json_file_get_root
generic,public :: update => MAYBEWRAP(json_file_update_integer), &
MAYBEWRAP(json_file_update_logical), &
MAYBEWRAP(json_file_update_real), &
MAYBEWRAP(json_file_update_string)
#ifdef USE_UCS4
generic,public :: update => json_file_update_string_name_ascii, &
json_file_update_string_val_ascii
#endif
!traverse
procedure,public :: traverse => json_file_traverse
! ***************************************************
! private routines
! ***************************************************
!load from string:
procedure :: MAYBEWRAP(json_file_load_from_string)
!initialize
procedure :: initialize_json_core_in_file
procedure :: set_json_core_in_file
!get info:
procedure :: MAYBEWRAP(json_file_variable_info)
procedure :: MAYBEWRAP(json_file_variable_matrix_info)
!get:
procedure :: MAYBEWRAP(json_file_get_object)
procedure :: MAYBEWRAP(json_file_get_integer)
procedure :: MAYBEWRAP(json_file_get_double)
procedure :: MAYBEWRAP(json_file_get_logical)
procedure :: MAYBEWRAP(json_file_get_string)
procedure :: MAYBEWRAP(json_file_get_integer_vec)
procedure :: MAYBEWRAP(json_file_get_double_vec)
procedure :: MAYBEWRAP(json_file_get_logical_vec)
procedure :: MAYBEWRAP(json_file_get_string_vec)
procedure :: json_file_get_root
!update:
procedure :: MAYBEWRAP(json_file_update_integer)
procedure :: MAYBEWRAP(json_file_update_logical)
procedure :: MAYBEWRAP(json_file_update_real)
procedure :: MAYBEWRAP(json_file_update_string)
#ifdef USE_UCS4
procedure :: json_file_update_string_name_ascii
procedure :: json_file_update_string_val_ascii
#endif
!print_file:
procedure :: json_file_print_to_console
procedure :: json_file_print_1
procedure :: json_file_print_2
end type json_file