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 JsonToProtoMessage
INSTANCE
-
Constructor Summary
Constructors Constructor Description JsonToProtoMessage()
You can useINSTANCE
instead
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods 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 Protobufcom.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.
-
-
-
Field Detail
-
INSTANCE
public static final JsonToProtoMessage INSTANCE
-
-
Constructor Detail
-
JsonToProtoMessage
public JsonToProtoMessage()
You can useINSTANCE
instead
-
-
Method Detail
-
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 interfaceToProtoConverter<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, BIGNUMERICjson
-- 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, BIGNUMERICjson
-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, BIGNUMERICjsonArray
-ignoreUnknownFields
- allows unknown fields in JSON input to be ignored.- Throws:
IllegalArgumentException
- when JSON data is not compatible with proto descriptor.
-
-