Striim 3.9.7 documentation

JSONFormatter

Formats a writer's output as JSON.

property

type

default value

notes

charset

java.lang.String

EventsAsArrayOfJsonObjects

java.lang.Boolean

True

With the default value True, output is an array:

[
  {field1:value1,field2:value2,.....} ,
  {field1:value1,field2:value2,.....} ,
  {field1:value1,field2:value2,.....} ]

Set to False to output a collection:

{field1:value1,field2:value2,.....} 
{field1:value1,field2:value2,.....} 
{field1:value1,field2:value2,.....}

jsonMemberDelimiter

java.lang.String

\n

jsonobjectdelimiter

java.lang.String

\n

members

java.lang.String

comma-separated list of fields to be selected from the writer's input stream; if left  blank, selects all fields

One use for this property is to remove fields used only to name the output directory in the target (see Setting output names and rollover / upload policies).

For example, this variation on the PosApp sample application writes to a file using JSONFormatter:

CREATE SOURCE CsvDataSource USING FileReader (
  directory:'Samples/PosApp/appData',
  wildcard:'PosDataPreview.csv',
  positionByEOF:false
)
PARSE USING DSVParser (
  header:Yes,
  trimquote:false
) OUTPUT TO CsvStream;
  
CREATE CQ CsvToPosData
INSERT INTO PosDataStream
SELECT TO_STRING(data[1]) as merchantId,
  TO_DOUBLE(data[7]) as amount,
  TO_STRING(data[9]) as zip
FROM CsvStream;

CREATE TARGET JFFileOut USING FileWriter(
  filename:'JFTestOutput.json'
)
FORMAT USING JSONFormatter()
INPUT FROM PosDataStream;

The first lines of JSONFormatterOutput are:

[
 {
  "merchantId":"D6RJPwyuLXoLqQRQcOcouJ26KGxJSf6hgbu",
  "dateTime":"2013-03-12T17:32:10.000-07:00",
  "amount":2.2
 },
 {
  "merchantId":"OFp6pKTMg26n1iiFY00M9uSqh9ZfMxMBRf1",
  "dateTime":"2013-03-12T17:32:10.000-07:00",
  "amount":22.78
 },