Options
- Subscribe to RSS Feed
- Mark Question as New
- Mark Question as Read
- Float this Question for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
Is there a way to iterate over array elements in Nifi?
Labels:
- Labels:
-
Apache NiFi
Explorer
Created ‎04-15-2019 09:30 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have an array ["a,1", "b,2"]. I want to iterate over the array and form a JSON {"a":1, "b":2)
What's the best way to achieve this?
1 REPLY 1
Master Guru
Created ‎04-16-2019 12:42 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You can use ExtractText processor to extract elements of Array then using Update attribute and ReplaceText processor we can create the final json.
Flow:
1.ExtractText //add new property with regex expression to extract a,1 2.ReplaceText //always replace as replacement strategy and use nifi expression language to prepare json.
(or)
Use the approach specified in this article 2.2 to iterate through array of elements and then use nifi expression language to create output flowfile in json format using ReplaceText processor.
