version 0.6.0
Loading...
Searching...
No Matches
JSON writer

JSON writer More...

Data Types

type  mod_json_writer::t_json
 JSON container. More...
 

Functions/Subroutines

subroutine mod_json_writer::json_up (json)
 Return to parent object.
 

Detailed Description

JSON writer conform to RFC 7159 (https://tools.ietf.org/html/rfc7159).

Example:

type(t_json) :: json
integer :: json_unit
! Generate an object without label
call json%add_object()
! Generate an object inside of previous object
call json%add_object()
! Generate 5 values of different types
call json%add(, 1)
call json%add(, 1d0)
call json%add(, )
call json%add(, .true.)
call json%add()
! Return to parent object
call json%up()
! Generate an object after the object
call json%add_object()
! Generate 4 arrays of different types
call json%add(, [1, 2, 3])
call json%add(, [1d0, 2d0, 3d0])
call json%add(, [, , ])
call json%add(, [.true., .false., .true.])
! Open a file
open(newunit=json_unit, file=, status=)
! Write the JSON container into the file . Note the 'DT' format.
write(json_unit,'(DT)') json
! Close the file
close(json_unit)
! Free memory
call json%finalize()

Expected output:

{
: {
: 1,
: 1.0000000000000000,
: ,
: true,
: null
},
: {
: [
1,
2,
3
],
: [
1.0000000000000000,
2.0000000000000000,
3.0000000000000000
],
: [
,
,
],
: [
true,
false,
true
]
}
}

Function/Subroutine Documentation

◆ json_up()

subroutine mod_json_writer::json_up ( class(t_json), intent(inout) json)
Parameters
[in,out]jsonJSON container