Low-level JSON token readers and I/O utilities.
Provides character-level JSON parsing primitives: whitespace skipping, string/number/bool reading, and value skipping. Also provides stdin and file reading utilities.
Expect and consume a specific character
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | json | |||
| integer, | intent(inout) | :: | pos | |||
| character(len=1), | intent(in) | :: | ch |
Skip whitespace characters
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | json | |||
| integer, | intent(inout) | :: | pos |
Read a JSON quoted string, advancing pos past closing quote. Unescapes standard JSON escape sequences.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | json | |||
| integer, | intent(inout) | :: | pos | |||
| character(len=:), | intent(out), | allocatable | :: | val | ||
| integer, | intent(out) | :: | status |
Read a JSON number as real(wp). Recognises JSON null and maps it to IEEE NaN.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | json | |||
| integer, | intent(inout) | :: | pos | |||
| real(kind=wp), | intent(out) | :: | val | |||
| integer, | intent(out) | :: | status |
Read a JSON integer
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | json | |||
| integer, | intent(inout) | :: | pos | |||
| integer, | intent(out) | :: | val | |||
| integer, | intent(out) | :: | status |
Read a JSON boolean (true/false)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | json | |||
| integer, | intent(inout) | :: | pos | |||
| logical, | intent(out) | :: | val | |||
| integer, | intent(out) | :: | status |
Read an arbitrary JSON value as a literal string. For strings returns the quoted content; for numbers, booleans, null returns the raw text.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | json | |||
| integer, | intent(inout) | :: | pos | |||
| character(len=:), | intent(out), | allocatable | :: | val | ||
| integer, | intent(out) | :: | status |
Skip an arbitrary JSON value (string, number, bool, null, object, or array) without storing it.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | json | |||
| integer, | intent(inout) | :: | pos |
Read entire stdin into a single string
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=:), | intent(out), | allocatable | :: | content | ||
| integer, | intent(out) | :: | status |
Read entire file into a single string
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | filename | |||
| character(len=:), | intent(out), | allocatable | :: | content | ||
| integer, | intent(out) | :: | status |