Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(json_value), | , | pointer | :: | p | output structure |
|
character(kind=CK,len=*), | intent(in) | :: | str | string with JSON data |
Parse the JSON string and populate the json_value tree.
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
integer(kind=IK), | public, | parameter | :: | iunit | = | 0 |
subroutine json_parse_string(p, str)
implicit none
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
if ( .not. exception_thrown ) then
!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 = ''
! parse as a value
call parse_value(unit=iunit, str=str, value=p)
if (exception_thrown) call annotate_invalid_json(iunit,str)
end if
end subroutine json_parse_string