Class VariantJsonParser

java.lang.Object
org.apache.parquet.variant.VariantJsonParser

public final class VariantJsonParser extends Object
Parses JSON into Variant values using Jackson streaming.

This class isolates the Jackson dependency from VariantBuilder, so that core variant construction does not require Jackson on the classpath.

Ported from Apache Spark's VariantBuilder.parseJson.

  • Method Details

    • parseJson

      public static Variant parseJson(String json) throws IOException
      Parses a JSON string and returns the corresponding Variant.

      Uses Jackson streaming parser for single-pass conversion with no intermediate tree. Number handling preserves precision: integers use the smallest fitting type, floating-point numbers prefer decimal encoding (no scientific notation) and fall back to double.

      Parameters:
      json - the JSON string to parse
      Returns:
      the parsed Variant
      Throws:
      IOException - if the JSON is malformed or an I/O error occurs
    • parseJson

      public static Variant parseJson(com.fasterxml.jackson.core.JsonParser parser) throws IOException
      Parses a JSON value from an already-positioned JsonParser and returns the corresponding Variant. The parser must have its current token set (i.e., parser.nextToken() or equivalent must have been called).
      Parameters:
      parser - a positioned Jackson JsonParser
      Returns:
      the parsed Variant
      Throws:
      IOException - if the JSON is malformed or an I/O error occurs