<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Array of JSON records to Avro with Nifi in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/Array-of-JSON-records-to-Avro-with-Nifi/m-p/162067#M124446</link>
    <description>&lt;P&gt;I have a JSON file containing an array of records and I'm trying to convert the entire JSON to Avro file using the &lt;STRONG&gt;ConvertJSONToAvro&lt;/STRONG&gt; processor.&lt;/P&gt;&lt;P&gt;JSON sample:&lt;/P&gt;&lt;PRE&gt;[
  {
    "id": 123,
    "title": "foo"
  },
  {
    "id": 345,
    "title": "bar"
  }
]
&lt;/PRE&gt;&lt;P&gt;Avro Schema:&lt;/P&gt;&lt;PRE&gt;{
  "name": "test",
  "type": "array",
  "items": {
    "type": "record",
    "name": "user",
    "fields": [
      {
        "name": "id",
        "type": "int"
      },
      {
        "name": "title",
        "type": "string"
      }
    ]
  }
}
&lt;/PRE&gt;&lt;P&gt;However using the above Avro schema the processor throws an exception:&lt;/P&gt;&lt;PRE&gt;java.lang.IllegalArgumentException: Schemas for JSON files should be record
	at org.kitesdk.shaded.com.google.common.base.Preconditions.checkArgument(Preconditions.java:88) ~[kite-data-core-1.0.0.jar:na]
	at org.kitesdk.data.spi.filesystem.JSONFileReader.initialize(JSONFileReader.java:84) ~[kite-data-core-1.0.0.jar:na]
	at org.apache.nifi.processors.kite.ConvertJSONToAvro$1.process(ConvertJSONToAvro.java:144) ~[nifi-kite-processors-1.1.0.2.1.1.0-2.jar:1.1.0.2.1.1.0-2]
	at org.apache.nifi.controller.repository.StandardProcessSession.write(StandardProcessSession.java:2578) ~[nifi-framework-core-1.1.0.2.1.1.0-2.jar:1.1.0.2.1.1.0-2]
	at org.apache.nifi.processors.kite.ConvertJSONToAvro.onTrigger(ConvertJSONToAvro.java:139) ~[nifi-kite-processors-1.1.0.2.1.1.0-2.jar:1.1.0.2.1.1.0-2]
	at org.apache.nifi.processor.AbstractProcessor.onTrigger(AbstractProcessor.java:27) ~[nifi-api-1.1.0.2.1.1.0-2.jar:1.1.0.2.1.1.0-2]
	at org.apache.nifi.controller.StandardProcessorNode.onTrigger(StandardProcessorNode.java:1099) [nifi-framework-core-1.1.0.2.1.1.0-2.jar:1.1.0.2.1.1.0-2]
	at org.apache.nifi.controller.tasks.ContinuallyRunProcessorTask.call(ContinuallyRunProcessorTask.java:136) [nifi-framework-core-1.1.0.2.1.1.0-2.jar:1.1.0.2.1.1.0-2]
	at org.apache.nifi.controller.tasks.ContinuallyRunProcessorTask.call(ContinuallyRunProcessorTask.java:47) [nifi-framework-core-1.1.0.2.1.1.0-2.jar:1.1.0.2.1.1.0-2]
	at org.apache.nifi.controller.scheduling.TimerDrivenSchedulingAgent$1.run(TimerDrivenSchedulingAgent.java:132) [nifi-framework-core-1.1.0.2.1.1.0-2.jar:1.1.0.2.1.1.0-2]


&lt;/PRE&gt;&lt;P&gt;Does this mean the ConvertJsonToAvro processor cannot convert an array of records, and I have to split the JSON file before feeding the records to this process? It seems like it doesn't recognise at  &lt;EM&gt;"type": "array"&lt;/EM&gt; at the root of the schema.&lt;/P&gt;</description>
    <pubDate>Fri, 17 Mar 2017 15:51:13 GMT</pubDate>
    <dc:creator>ithoughtful</dc:creator>
    <dc:date>2017-03-17T15:51:13Z</dc:date>
  </channel>
</rss>

