Thank you, works on the Jolt demo site. With real Nifi it doesn't. I am
trying to print those values in ExecuteScript with Groovy script iterating
flowfile attributets:
import org.apache.commons.io.IOUtils
import java.nio.charset.StandardCharsets
import org.apache.nifi.processor.io.StreamCallback
def flowFile = session.get()
def file1 = new File('/home/me/groovy/attributes.txt')
file1.write '##############################################\n'
flowFile.getAttributes().each { key,value ->
file1.append(key+' :')
file1.append(value + '\n')
}
session.transfer(flowFile,REL_SUCCESS)
None of them show up. Is there some way to read them from ExecuteScript?
On Tue, Sep 4, 2018 at 12:56 PM Matt Burgess <[email protected]> wrote:
> Add the following to the end of your shift spec:
>
> "*": "&"
>
> This (at the root) matches any key not already matched and puts it in
> the output at the same location.
>
> Regards,
> Matt
>
> On Tue, Sep 4, 2018 at 11:39 AM l vic <[email protected]> wrote:
> >
> > Hi,
> > I want to "flatten" the following object:
> > {
> > "id": 0,
> > "name": "Root",
> > "mylist": [{
> > "id": 10,
> > "info": "2am-3am"
> > },
> > {
> > "id": 11,
> > "info": "3AM-4AM"
> > },
> > {
> > "id": 12,
> > "info": "4am-5am"
> > }]
> > }
> > I figured how to "flatten" array, but "root" values are gone in
> transformed output:
> > {
> > "mylist-0-id":10,
> > " mylist-0-info":"2am-3am",
> > ....
> > }
> > How can I retain "root" fields so that transformed output would like
> like one below?
> > {
> > "id": 0,
> > "name": "Root",
> > "mylist-0-id":10,
> > " mylist-0-info":"2am-3am",
> > ....
> > }
> >
> >
>