Class JsonToProtoMessage

java.lang.Object
com.google.cloud.bigquery.storage.v1.JsonToProtoMessage
All Implemented Interfaces:
ToProtoConverter<Object>

public class JsonToProtoMessage extends Object implements ToProtoConverter<Object>
Converts JSON data to Protobuf messages given the Protobuf descriptor and BigQuery table schema. The Protobuf descriptor must have all fields lowercased.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final JsonToProtoMessage
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    You can use INSTANCE instead
  • Method Summary

    Modifier and Type
    Method
    Description
    static com.google.protobuf.DynamicMessage
    convertJsonToProtoMessage(com.google.protobuf.Descriptors.Descriptor protoSchema, TableSchema tableSchema, org.json.JSONObject json)
     
    static com.google.protobuf.DynamicMessage
    convertJsonToProtoMessage(com.google.protobuf.Descriptors.Descriptor protoSchema, TableSchema tableSchema, org.json.JSONObject json, boolean ignoreUnknownFields)
     
    static com.google.protobuf.DynamicMessage
    convertJsonToProtoMessage(com.google.protobuf.Descriptors.Descriptor protoSchema, org.json.JSONObject json)
     
    List<com.google.protobuf.DynamicMessage>
    convertToProtoMessage(com.google.protobuf.Descriptors.Descriptor protoSchema, TableSchema tableSchema, Iterable<Object> jsonArray, boolean ignoreUnknownFields)
    Converts Json array to list of Protobuf
    com.google.protobuf.DynamicMessage
    convertToProtoMessage(com.google.protobuf.Descriptors.Descriptor protoSchema, TableSchema tableSchema, Object json, boolean ignoreUnknownFields)
    Converts input message to Protobuf.
    List<com.google.protobuf.DynamicMessage>
    convertToProtoMessage(com.google.protobuf.Descriptors.Descriptor protoSchema, TableSchema tableSchema, org.json.JSONArray jsonArray, boolean ignoreUnknownFields)
    Converts Json array to list of protocol buffer messages given the protocol buffer descriptor.
    com.google.protobuf.DynamicMessage
    convertToProtoMessage(com.google.protobuf.Descriptors.Descriptor protoSchema, TableSchema tableSchema, org.json.JSONObject json)
    Converts Json data to protocol buffer messages given the protocol buffer descriptor.
    com.google.protobuf.DynamicMessage
    convertToProtoMessage(com.google.protobuf.Descriptors.Descriptor protoSchema, TableSchema tableSchema, org.json.JSONObject json, boolean ignoreUnknownFields)
    Converts Json data to protocol buffer messages given the protocol buffer descriptor.
    com.google.protobuf.DynamicMessage
    convertToProtoMessage(com.google.protobuf.Descriptors.Descriptor protoSchema, org.json.JSONObject json)
    Converts Json data to protocol buffer messages given the protocol buffer descriptor.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • JsonToProtoMessage

      public JsonToProtoMessage()
      You can use INSTANCE instead
  • Method Details

    • convertJsonToProtoMessage

      public static com.google.protobuf.DynamicMessage convertJsonToProtoMessage(com.google.protobuf.Descriptors.Descriptor protoSchema, TableSchema tableSchema, org.json.JSONObject json, boolean ignoreUnknownFields)
    • convertJsonToProtoMessage

      public static com.google.protobuf.DynamicMessage convertJsonToProtoMessage(com.google.protobuf.Descriptors.Descriptor protoSchema, org.json.JSONObject json)
    • convertJsonToProtoMessage

      public static com.google.protobuf.DynamicMessage convertJsonToProtoMessage(com.google.protobuf.Descriptors.Descriptor protoSchema, TableSchema tableSchema, org.json.JSONObject json)
    • convertToProtoMessage

      public com.google.protobuf.DynamicMessage convertToProtoMessage(com.google.protobuf.Descriptors.Descriptor protoSchema, TableSchema tableSchema, Object json, boolean ignoreUnknownFields)
      Converts input message to Protobuf.

      WARNING: it's much more efficient to call the other APIs accepting json array if the jsons share the same table schema.

      Parameters:
      protoSchema - the schema of the output Protobuf schems.
      tableSchema - tha underlying table schema for which Protobuf is being built.
      json - the input JSON object converted to Protobuf.
      ignoreUnknownFields - flag indicating that the additional fields not present in the output schema should be accepted.
      Returns:
      Converted message in Protobuf format.
    • convertToProtoMessage

      public List<com.google.protobuf.DynamicMessage> convertToProtoMessage(com.google.protobuf.Descriptors.Descriptor protoSchema, TableSchema tableSchema, Iterable<Object> jsonArray, boolean ignoreUnknownFields)
      Converts Json array to list of Protobuf
      Specified by:
      convertToProtoMessage in interface ToProtoConverter<Object>
      Parameters:
      protoSchema - the schema of the output Protobuf schems.
      tableSchema - tha underlying table schema for which Protobuf is being built.
      jsonArray - the input JSON array converted to Protobuf.
      ignoreUnknownFields - flag indicating that the additional fields not present in the output schema should be accepted.
      Returns:
      Converted message in Protobuf format.
    • convertToProtoMessage

      public com.google.protobuf.DynamicMessage convertToProtoMessage(com.google.protobuf.Descriptors.Descriptor protoSchema, org.json.JSONObject json) throws IllegalArgumentException
      Converts Json data to protocol buffer messages given the protocol buffer descriptor.

      WARNING: it's much more efficient to call the other APIs accepting json array if the jsons share the same table schema.

      Parameters:
      protoSchema -
      json -
      Throws:
      IllegalArgumentException - when JSON data is not compatible with proto descriptor.
    • convertToProtoMessage

      public com.google.protobuf.DynamicMessage convertToProtoMessage(com.google.protobuf.Descriptors.Descriptor protoSchema, TableSchema tableSchema, org.json.JSONObject json) throws IllegalArgumentException
      Converts Json data to protocol buffer messages given the protocol buffer descriptor.

      WARNING: it's much more efficient to call the other APIs accepting json array if the jsons share the same table schema.

      Parameters:
      protoSchema -
      tableSchema - bigquery table schema is needed for type conversion of DATETIME, TIME, NUMERIC, BIGNUMERIC
      json -
      Throws:
      IllegalArgumentException - when JSON data is not compatible with proto descriptor.
    • convertToProtoMessage

      public com.google.protobuf.DynamicMessage convertToProtoMessage(com.google.protobuf.Descriptors.Descriptor protoSchema, TableSchema tableSchema, org.json.JSONObject json, boolean ignoreUnknownFields) throws IllegalArgumentException
      Converts Json data to protocol buffer messages given the protocol buffer descriptor.

      WARNING: it's much more efficient to call the other APIs accepting json array if the jsons share the same table schema.

      Parameters:
      protoSchema -
      tableSchema - bigquery table schema is needed for type conversion of DATETIME, TIME, NUMERIC, BIGNUMERIC
      json -
      ignoreUnknownFields - allows unknown fields in JSON input to be ignored.
      Throws:
      IllegalArgumentException - when JSON data is not compatible with proto descriptor.
    • convertToProtoMessage

      public List<com.google.protobuf.DynamicMessage> convertToProtoMessage(com.google.protobuf.Descriptors.Descriptor protoSchema, TableSchema tableSchema, org.json.JSONArray jsonArray, boolean ignoreUnknownFields) throws IllegalArgumentException
      Converts Json array to list of protocol buffer messages given the protocol buffer descriptor.
      Parameters:
      protoSchema -
      tableSchema - bigquery table schema is needed for type conversion of DATETIME, TIME, NUMERIC, BIGNUMERIC
      jsonArray -
      ignoreUnknownFields - allows unknown fields in JSON input to be ignored.
      Throws:
      IllegalArgumentException - when JSON data is not compatible with proto descriptor.