json_value Derived Type

Type used to construct the linked-list JSON structure. Normally, this should always be a pointer variable.

Example

The following test program:

    program test
     use json_module
     implicit none
     type(json_value),pointer :: p
     call json_initialize()         !initialize the module
     call json_create_object(p,'')  !create the root
     call json_add(p,'year',1805)   !add some data
     call json_add(p,'value',1.0d0) !add some data
     call json_print(p,'test.json') !write it to a file
     call json_destroy(p)           !cleanup
    end program test

Produces the JSON file test.json:

    {
      "year": 1805,
      "value": 0.1E+1
    }

Components

TypeVisibility AttributesNameInitial
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


Source Code

    type,public :: json_value

        !force the constituents to be stored contiguously
        ![note: on Intel, the order of the variables below
        ! is significant to avoid the misaligned field warnings]
        sequence

        private

        !for the linked list:
        type(json_value),pointer :: previous => null()  !! previous item in the list
        type(json_value),pointer :: next     => null()  !! next item in the list
        type(json_value),pointer :: parent   => null()  !! parent item of this
        type(json_value),pointer :: children => null()  !! first child item of this
        type(json_value),pointer :: tail     => null()  !! last child item of this

        character(kind=CK,len=:),allocatable :: name  !! variable name

        real(RK),allocatable                 :: dbl_value  !! real data for this variable
        logical(LK),allocatable              :: log_value  !! logical data for this variable
        character(kind=CK,len=:),allocatable :: str_value  !! string data for this variable
        integer(IK),allocatable              :: int_value  !! integer data for this variable

        integer(IK) :: var_type = json_unknown  !! variable type

        integer(IK),private :: n_children = 0   !! number of children

    end type json_value

© 2015 JSON-Fortran was written by Jacob Williams.
Documentation generated by FORD.