Class JsonToProtoMessage (2.38.0)

public class JsonToProtoMessage 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.

Inheritance

Object > JsonToProtoMessage

Implements

com.google.cloud.bigquery.storage.v1.ToProtoConverter<java.lang.Object>

Static Fields

INSTANCE

public static final JsonToProtoMessage INSTANCE
Field Value
TypeDescription
JsonToProtoMessage

Static Methods

convertJsonToProtoMessage(Descriptors.Descriptor protoSchema, TableSchema tableSchema, JSONObject json)

public static DynamicMessage convertJsonToProtoMessage(Descriptors.Descriptor protoSchema, TableSchema tableSchema, JSONObject json)
Parameters
NameDescription
protoSchemaDescriptor
tableSchemaTableSchema
jsonorg.json.JSONObject
Returns
TypeDescription
DynamicMessage

convertJsonToProtoMessage(Descriptors.Descriptor protoSchema, TableSchema tableSchema, JSONObject json, boolean ignoreUnknownFields)

public static DynamicMessage convertJsonToProtoMessage(Descriptors.Descriptor protoSchema, TableSchema tableSchema, JSONObject json, boolean ignoreUnknownFields)
Parameters
NameDescription
protoSchemaDescriptor
tableSchemaTableSchema
jsonorg.json.JSONObject
ignoreUnknownFieldsboolean
Returns
TypeDescription
DynamicMessage

convertJsonToProtoMessage(Descriptors.Descriptor protoSchema, JSONObject json)

public static DynamicMessage convertJsonToProtoMessage(Descriptors.Descriptor protoSchema, JSONObject json)
Parameters
NameDescription
protoSchemaDescriptor
jsonorg.json.JSONObject
Returns
TypeDescription
DynamicMessage

Constructors

JsonToProtoMessage()

public JsonToProtoMessage()

You can use #INSTANCE instead

Methods

convertToProtoMessage(Descriptors.Descriptor protoSchema, TableSchema tableSchema, Object json, boolean ignoreUnknownFields)

public DynamicMessage convertToProtoMessage(Descriptors.Descriptor protoSchema, TableSchema tableSchema, Object json, boolean ignoreUnknownFields)

Converts input message to Protobuf

Parameters
NameDescription
protoSchemaDescriptor

the schema of the output Protobuf schems.

tableSchemaTableSchema

tha underlying table schema for which Protobuf is being built.

jsonObject

the input JSON object converted to Protobuf.

ignoreUnknownFieldsboolean

flag indicating that the additional fields not present in the output schema should be accepted.

Returns
TypeDescription
DynamicMessage

Converted message in Protobuf format.

convertToProtoMessage(Descriptors.Descriptor protoSchema, TableSchema tableSchema, JSONObject json)

public DynamicMessage convertToProtoMessage(Descriptors.Descriptor protoSchema, TableSchema tableSchema, JSONObject json)

Converts Json data to protocol buffer messages given the protocol buffer descriptor.

Parameters
NameDescription
protoSchemaDescriptor
tableSchemaTableSchema

bigquery table schema is needed for type conversion of DATETIME, TIME, NUMERIC, BIGNUMERIC

jsonorg.json.JSONObject
Returns
TypeDescription
DynamicMessage
Exceptions
TypeDescription
IllegalArgumentException

when JSON data is not compatible with proto descriptor.

convertToProtoMessage(Descriptors.Descriptor protoSchema, TableSchema tableSchema, JSONObject json, boolean ignoreUnknownFields)

public DynamicMessage convertToProtoMessage(Descriptors.Descriptor protoSchema, TableSchema tableSchema, JSONObject json, boolean ignoreUnknownFields)

Converts Json data to protocol buffer messages given the protocol buffer descriptor.

Parameters
NameDescription
protoSchemaDescriptor
tableSchemaTableSchema

bigquery table schema is needed for type conversion of DATETIME, TIME, NUMERIC, BIGNUMERIC

jsonorg.json.JSONObject
ignoreUnknownFieldsboolean

allows unknown fields in JSON input to be ignored.

Returns
TypeDescription
DynamicMessage
Exceptions
TypeDescription
IllegalArgumentException

when JSON data is not compatible with proto descriptor.

convertToProtoMessage(Descriptors.Descriptor protoSchema, JSONObject json)

public DynamicMessage convertToProtoMessage(Descriptors.Descriptor protoSchema, JSONObject json)

Converts Json data to protocol buffer messages given the protocol buffer descriptor.

Parameters
NameDescription
protoSchemaDescriptor
jsonorg.json.JSONObject
Returns
TypeDescription
DynamicMessage
Exceptions
TypeDescription
IllegalArgumentException

when JSON data is not compatible with proto descriptor.