Append one integer value stored as a quoted JSON string.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | line |
Current JSON line inside a multiline integer array |
||
| integer, | intent(inout), | allocatable | :: | values(:) |
Mutable integer array buffer updated in-place |
subroutine append_json_int_string_item(line, values) !! Append one integer value stored as a quoted JSON string. implicit none ! Arguments character(*), intent(in) :: line !! Current JSON line inside a multiline integer array integer, allocatable, intent(inout) :: values(:) !! Mutable integer array buffer updated in-place ! Local variables integer :: pos1, pos2, parsed_value, stat !! Quote positions plus parsed integer value and read status character(32) :: value !! Extracted numeric token before conversion if(index(line, '"') .eq. 0) return pos1 = index(line, '"') if(pos1 .le. 0) return pos2 = index(line(pos1+1:), '"') if(pos2 .le. 0) return value = line(pos1+1:pos1+pos2-1) read(value, *, iostat=stat) parsed_value if(stat .ne. 0) return if(.not.allocated(values))then allocate(values(1)) values(1) = parsed_value else values = [values, parsed_value] end if end subroutine append_json_int_string_item