JSON writer
More...
JSON writer
JSON writer conform to RFC 7159 (https://tools.ietf.org/html/rfc7159).
Example:
type(t_json) :: json
integer :: json_unit
call json%add_object()
call json%add_object()
call json%add(, 1)
call json%add(, 1d0)
call json%add(, )
call json%add(, .true.)
call json%add()
call json%up()
call json%add_object()
call json%add(, [1, 2, 3])
call json%add(, [1d0, 2d0, 3d0])
call json%add(, [, , ])
call json%add(, [.true., .false., .true.])
open(newunit=json_unit, file=, status=)
write(json_unit,'(DT)') json
close(json_unit)
call json%finalize()
Expected output:
{
: {
: 1,
: 1.0000000000000000,
: ,
: true,
: null
},
: {
: [
1,
2,
3
],
: [
1.0000000000000000,
2.0000000000000000,
3.0000000000000000
],
: [
,
,
],
: [
true,
false,
true
]
}
}
◆ json_add_array()
| subroutine mod_json_writer::json_add_array |
( |
class(t_json), intent(inout) | json, |
|
|
character(len=*), intent(in) | key ) |
|
private |
Add an empty array.
- Parameters
-
| [in,out] | json | JSON container |
| [in] | key | Label of the array |
◆ json_add_object()
| subroutine mod_json_writer::json_add_object |
( |
class(t_json), intent(inout) | json, |
|
|
character(len=*), intent(in) | key ) |
|
private |
Add an empty object.
- Parameters
-
| [in,out] | json | JSON container |
| [in] | key | Label of the object |
◆ json_finalize()
| subroutine mod_json_writer::json_finalize |
( |
type(t_json), intent(inout) | json | ) |
|
|
private |
Unalloc the structure.
- Parameters
-
| [in,out] | json | JSON container |
◆ json_up()
| subroutine mod_json_writer::json_up |
( |
class(t_json), intent(inout) | json | ) |
|
Return to parent object.
- Parameters
-
| [in,out] | json | JSON container |