Parse the JSON string and populate the json_value tree.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(json_core), | intent(inout) | :: | json | |||
type(json_value), | pointer | :: | p | output structure |
||
character(kind=CK,len=*), | intent(in) | :: | str | string with JSON data |
Nodes of different colours represent the following:
Solid arrows point from a procedure to one which it calls. Dashed arrows point from an interface to procedures which implement that interface. This could include the module procedures in a generic interface or the implementation in a submodule of an interface in a parent module. Where possible, edges connecting nodes are given different colours to make them easier to distinguish in large graphs.
subroutine json_parse_string(json, p, str)
implicit none
class(json_core),intent(inout) :: json
type(json_value),pointer :: p !! output structure
character(kind=CK,len=*),intent(in) :: str !! string with JSON data
integer(IK),parameter :: iunit = 0 !! indicates that json data will be read from buffer
!clear any exceptions and initialize:
call json%initialize()
! create the value and associate the pointer
call json_value_create(p)
! Note: the name of the root json_value doesn't really matter,
! but we'll allocate something here just in case.
p%name = CK_''
! parse as a value
call json%parse_value(unit=iunit, str=str, value=p)
if (json%exception_thrown) call json%annotate_invalid_json(iunit,str)
end subroutine json_parse_string