JsonRecordSetWriter

Description:

Writes the results of a RecordSet as either a JSON Array or one JSON object per line. If using Array output, then even if the RecordSet consists of a single row, it will be written as an array with a single element. If using One Line Per Object output, the JSON objects cannot be pretty-printed.

Tags:

json, resultset, writer, serialize, record, recordset, row

Properties:

In the list below, the names of required properties appear in bold. Any other properties (not in bold) are considered optional. The table also indicates any default values, and whether a property supports the NiFi Expression Language.

Display NameAPI NameDefault ValueAllowable ValuesDescription
Schema Write StrategySchema Write StrategyDo Not Write Schema
  • Do Not Write Schema Do not add any schema-related information to the FlowFile.
  • Set 'schema.name' Attribute The FlowFile will be given an attribute named 'schema.name' and this attribute will indicate the name of the schema in the Schema Registry. Note that ifthe schema for a record is not obtained from a Schema Registry, then no attribute will be added.
  • Set 'avro.schema' Attribute The FlowFile will be given an attribute named 'avro.schema' and this attribute will contain the Avro Schema that describes the records in the FlowFile. The contents of the FlowFile need not be Avro, but the text of the schema will be used.
  • HWX Schema Reference Attributes The FlowFile will be given a set of 3 attributes to describe the schema: 'schema.identifier', 'schema.version', and 'schema.protocol.version'. Note that if the schema for a record does not contain the necessary identifier and version, an Exception will be thrown when attempting to write the data.
  • HWX Content-Encoded Schema Reference The content of the FlowFile will contain a reference to a schema in the Schema Registry service. The reference is encoded as a single byte indicating the 'protocol version', followed by 8 bytes indicating the schema identifier, and finally 4 bytes indicating the schema version, as per the Hortonworks Schema Registry serializers and deserializers, as found at https://github.com/hortonworks/registry. This will be prepended to each FlowFile. Note that if the schema for a record does not contain the necessary identifier and version, an Exception will be thrown when attempting to write the data.
  • Confluent Schema Registry Reference The content of the FlowFile will contain a reference to a schema in the Schema Registry service. The reference is encoded as a single 'Magic Byte' followed by 4 bytes representing the identifier of the schema, as outlined at http://docs.confluent.io/current/schema-registry/docs/serializer-formatter.html. This will be prepended to each FlowFile. Note that if the schema for a record does not contain the necessary identifier and version, an Exception will be thrown when attempting to write the data. This is based on the encoding used by version 3.2.x of the Confluent Schema Registry.
Specifies how the schema for a Record should be added to the data.
Schema Cacheschema-cacheController Service API:
RecordSchemaCacheService
Implementation: VolatileSchemaCache
Specifies a Schema Cache to add the Record Schema to so that Record Readers can quickly lookup the schema.
Schema Protocol Versionschema-protocol-version1The protocol version to be used for Schema Write Strategies that require a protocol version, such as Hortonworks Schema Registry strategies. Valid protocol versions for Hortonworks Schema Registry are integer values 1, 2, or 3.
Supports Expression Language: true (will be evaluated using flow file attributes and variable registry)

This Property is only considered if the [Schema Write Strategy] Property is set to one of the following values: [HWX Schema Reference Attributes], [HWX Content-Encoded Schema Reference]
Schema Access Strategyschema-access-strategyInherit Record Schema
  • Inherit Record Schema The schema used to write records will be the same schema that was given to the Record when the Record was created.
  • Use 'Schema Name' Property The name of the Schema to use is specified by the 'Schema Name' Property. The value of this property is used to lookup the Schema in the configured Schema Registry service.
  • Use 'Schema Text' Property The text of the Schema itself is specified by the 'Schema Text' Property. The value of this property must be a valid Avro Schema. If Expression Language is used, the value of the 'Schema Text' property must be valid after substituting the expressions.
Specifies how to obtain the schema that is to be used for interpreting the data.
Schema Registryschema-registryController Service API:
SchemaRegistry
Implementations: ConfluentSchemaRegistry
AmazonGlueSchemaRegistry
HortonworksSchemaRegistry
DatabaseTableSchemaRegistry
AvroSchemaRegistry
Specifies the Controller Service to use for the Schema Registry

This Property is only considered if the [Schema Access Strategy] Property is set to one of the following values: [Use 'Schema Name' Property]
Schema Nameschema-name${schema.name}Specifies the name of the schema to lookup in the Schema Registry property
Supports Expression Language: true (will be evaluated using flow file attributes and variable registry)

This Property is only considered if the [Schema Access Strategy] Property has a value of "Use 'Schema Name' Property".
Schema Versionschema-versionSpecifies the version of the schema to lookup in the Schema Registry. If not specified then the latest version of the schema will be retrieved.
Supports Expression Language: true (will be evaluated using flow file attributes and variable registry)

This Property is only considered if the [Schema Access Strategy] Property has a value of "Use 'Schema Name' Property".
Schema Branchschema-branchSpecifies the name of the branch to use when looking up the schema in the Schema Registry property. If the chosen Schema Registry does not support branching, this value will be ignored.
Supports Expression Language: true (will be evaluated using flow file attributes and variable registry)

This Property is only considered if the [Schema Access Strategy] Property has a value of "Use 'Schema Name' Property".
Schema Textschema-text${avro.schema}The text of an Avro-formatted Schema
Supports Expression Language: true (will be evaluated using flow file attributes and variable registry)

This Property is only considered if the [Schema Access Strategy] Property has a value of "Use 'Schema Text' Property".
Date FormatDate FormatSpecifies the format to use when reading/writing Date fields. If not specified, Date fields will be assumed to be number of milliseconds since epoch (Midnight, Jan 1, 1970 GMT). If specified, the value must match the Java Simple Date Format (for example, MM/dd/yyyy for a two-digit month, followed by a two-digit day, followed by a four-digit year, all separated by '/' characters, as in 01/01/2017).
Time FormatTime FormatSpecifies the format to use when reading/writing Time fields. If not specified, Time fields will be assumed to be number of milliseconds since epoch (Midnight, Jan 1, 1970 GMT). If specified, the value must match the Java Simple Date Format (for example, HH:mm:ss for a two-digit hour in 24-hour format, followed by a two-digit minute, followed by a two-digit second, all separated by ':' characters, as in 18:04:15).
Timestamp FormatTimestamp FormatSpecifies the format to use when reading/writing Timestamp fields. If not specified, Timestamp fields will be assumed to be number of milliseconds since epoch (Midnight, Jan 1, 1970 GMT). If specified, the value must match the Java Simple Date Format (for example, MM/dd/yyyy HH:mm:ss for a two-digit month, followed by a two-digit day, followed by a four-digit year, all separated by '/' characters; and then followed by a two-digit hour in 24-hour format, followed by a two-digit minute, followed by a two-digit second, all separated by ':' characters, as in 01/01/2017 18:04:15).
Pretty Print JSONPretty Print JSONfalse
  • true
  • false
Specifies whether or not the JSON should be pretty printed
Suppress Null Valuessuppress-nullsNever Suppress
  • Never Suppress Fields that are missing (present in the schema but not in the record), or that have a value of null, will be written out as a null value
  • Always Suppress Fields that are missing (present in the schema but not in the record), or that have a value of null, will not be written out
  • Suppress Missing Values When a field has a value of null, it will be written out. However, if a field is defined in the schema and not present in the record, the field will not be written out.
Specifies how the writer should handle a null field
Allow Scientific NotationAllow Scientific Notationfalse
  • true
  • false
Specifies whether or not scientific notation should be used when writing numbers
Output Groupingoutput-groupingArray
  • Array Output records as a JSON array
  • One Line Per Object Output records with one JSON object per line, delimited by a newline character
Specifies how the writer should output the JSON records (as an array or one object per line, e.g.) Note that if 'One Line Per Object' is selected, then Pretty Print JSON must be false.
Compression Formatcompression-formatnone
  • none
  • gzip
  • bzip2
  • xz-lzma2
  • snappy
  • snappy framed
  • zstd
The compression format to use. Valid values are: GZIP, BZIP2, ZSTD, XZ-LZMA2, LZMA, Snappy, and Snappy Framed
Compression Levelcompression-level1
  • 0
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
The compression level to use; this is valid only when using GZIP compression. A lower value results in faster processing but less compression; a value of 0 indicates no compression but simply archiving

This Property is only considered if the [Compression Format] Property has a value of "gzip".

State management:

This component does not store state.

Restricted:

This component is not restricted.

System Resource Considerations:

None specified.