detect_json_section Subroutine

subroutine detect_json_section(line, parser)

Detect the active top-level graph section.

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: line

Current trimmed JSON line

type(json_parser_state_type), intent(inout) :: parser

Parser state with mutable active section


Source Code

  subroutine detect_json_section(line, parser)
    !! Detect the active top-level graph section.
    implicit none

    ! Arguments
    character(*), intent(in) :: line
    !! Current trimmed JSON line
    type(json_parser_state_type), intent(inout) :: parser
    !! Parser state with mutable active section

    if(len_trim(parser%section) .gt. 0) return

    if(index(line, '"node"') .gt. 0 .and. index(line, '[') .gt. 0)then
       parser%section = 'node'
       return
    end if

    if(index(line, '"initializer"') .gt. 0 .and. index(line, '[') .gt. 0)then
       parser%section = 'initializer'
       return
    end if

    if(index(line, '"input"') .gt. 0 .and. index(line, '[') .gt. 0)then
       parser%section = 'input'
       return
    end if

    if(index(line, '"output"') .gt. 0 .and. index(line, '[') .gt. 0)then
       parser%section = 'output'
       return
    end if

    if(index(line, '"metadataProps"') .gt. 0 .and. index(line, '[') .gt. 0)then
       parser%section = 'metadata'
    end if

  end subroutine detect_json_section