JSONEncoder

managedwriter. JSONEncoder

Internal class used by the JSONWriter to convert JSON data to protobuf messages. It can be configure to do some data conversion to match what BigQuery expects.

Constructor

new JSONEncoder(params)

Creates a new JSONEncoder instance.

Parameters:
Name Type Description
params Object

The parameters for the JSONEncoder.

Properties
Name Type Description
protoDescriptor IDescriptorProto

The proto descriptor for the JSON rows.

Methods

encodeRows(rows) → {Array.<Uint8Array>}

Writes a JSONList that contains objects to be written to the BigQuery table by first converting the JSON data to protobuf messages, then using Writer's appendRows() to write the data at current end of stream. If there is a schema update, the current Writer is closed and reopened with the updated schema.

Parameters:
Name Type Description
rows JSONList

The list of JSON rows.

Returns:
Type Description
Array.<Uint8Array>

The encoded rows.

setProtoDescriptor(protoDescriptor)

Update the proto descriptor for the Encoder.

Parameters:
Name Type Description
protoDescriptor IDescriptorProto

The proto descriptor.