JsonParser
Parses JSON text straight into the Variant encoding.
The parser reads UTF-8 bytes, not a decoded String, for two reasons that both matter to an ingest path: a string with no escapes is copied into the value byte-for-byte with no decode and no re-encode, and every error carries an exact byte offset into the input the caller handed over.
Input is validated strictly. Malformed UTF-8, unescaped control characters, unpaired surrogate escapes, leading zeros and trailing content are all rejected with a position — an ingest engine that quietly repairs its input is one that stores something the caller never wrote.
val variant = Variant.fromJson("""{"id":7,"tags":["a","b"]}""")
// Segment ingest: one dictionary, one builder, many documents.
val builder = VariantBuilder(dictionary)
for (document in documents) {
builder.reset()
parser.parseInto(builder, document)
store(builder.build())
}Content copied to clipboard
Instances are stateless and safe to reuse; the parse itself is single-threaded.