Member since
07-06-2018
5
Posts
0
Kudos Received
0
Solutions
07-11-2018
08:39 AM
1 Kudo
@Sam LL You can do this in NiFi by using Record oriented processors (ConvertRecord). Using Convert Record processor: input json: {
NAME: "xxx",
CITY: "yyy",
AGE:"00",
ZIPCODE: "12345",
ADDRESS: " "}
Use ConvertRecord processor with Json Tree reader as controller service and give your matching avro schema and enable controller service. Avro Schema: {
"namespace": "nifi",
"name": "balances",
"type": "record",
"fields": [
{"name": "NAME", "type": ["null", "string"]},
{"name": "CITY", "type": ["null", "string"]},
{"name": "AGE", "type": ["null", "string"]},
{"name": "ZIPCODE", "type": ["null", "string"]},
{"name": "ADDRESS", "type": ["null", "string"]}
]
} By using the configured reader convertRecord processor is able to read your incoming data. To write in json format configure/enable JsonRecordSetWriter controller service and give the matching avro schema(change the order of the fields while writing) AvroSchema: {
"namespace": "nifi",
"name": "balances",
"type": "record",
"fields": [
{"name": "NAME", "type": ["null", "string"]},
{"name": "AGE", "type": ["null", "string"]},
{"name": "ADDRESS", "type": ["null", "string"]},
{"name": "CITY", "type": ["null", "string"]},
{"name": "ZIPCODE", "type": ["null", "string"]}
]
} Now while writing the output data processor writes with the matching avro schema with ordering the fields in same way Output: [{"NAME":"xxx","AGE":"00","ADDRESS":" ","CITY":"yyy","ZIPCODE":"12345"}] Refer to this link for configure/enabling ConvertRecord processor. - If the Answer helped to resolve your issue, Click on Accept button below to accept the answer.
... View more
07-07-2018
02:36 AM
@ShuThank you very much
... View more