How to write JSON data into SQL table
Day 4:
Today we are going to see how to read a JSON file and write it into a SQL table.
We can get files into nifi flow by using the GetFile processor.
In the highlighted areas we have to mention the input file directory. If we keep a false in “Keep Source File” property processor will remove source else if we keep true then processor won’t remove source file.
The next step is to extract data from JSON files. By using the EvaluateJsonPath processor, we can convert json data into flowfile attributes.
In the example below, we have two keys and values,
{
“name”:”abc”,
“id”:”1”
}
To extract values from them we have to call keys like below,
Name = $.name
Id = $.id
While constructing queries called flowfile attributes in place of values, we can insert JSON values into DB.
Please refer to my previous post for inserting data into SQL DB.