Interface JsonParser
- All Superinterfaces:
AutoCloseable
Implementations are responsible for reading one JSON object per call
from the underlying input stream and returning its fields as a
Map keyed by column name.
Iteration-order contract
The reader infers its column schema from the keys of the first
row, in iteration order, and uses that order to resolve 1-based column
indexes for every subsequent row. Implementations must therefore
return a Map that preserves the insertion order of the JSON keys
as they appeared on the wire (e.g. LinkedHashMap); a
hash-ordered HashMap is not acceptable because it
destabilises index-based access.
The bundled JacksonJsonParserFactory (which produces
LinkedHashMap via Jackson's Map.class default)
and GsonJsonParserFactory (which produces LinkedTreeMap)
both satisfy this contract. Custom implementations must take care not to
regress it.
-
Method Summary
Methods inherited from interface java.lang.AutoCloseable
close
-
Method Details
-
nextRow
Reads next row from the input stream.The returned map must preserve the insertion order of the JSON keys as defined by the interface contract.
- Returns:
- map of column names to values, or null if no more rows
- Throws:
Exception- if an error occurs during parsing
-