0

This is the script I have written to replace value of All in jsonData with response. But I am getting error on line 22 mentioned below of unexpected character'(' on line 22. I'm unable to figure out if there is any mistake in script please help with this

import groovy.json.JsonBuilder
import groovy.json.JsonSlurper
import org.apache.commons.io.IOUtils
import org.apache.groovy.json.internal.LazyMap
import org.apache.commons.io.IOUtils
import org.apache.nifi.processor.io.StreamCallback
import java.nio.charset.StandardCharsets

def flowfile=session.get();
if(flowfile==null){return;}
flowfile=session.write(flowfile,{inputStream,outputStream->
def content=IOUtils.toString(inputStream,StandardCharsets.UTF_8)
def inJson=new JsonSlurper().parseText(content)
String apiResult=flowfile.getAttribute("response")
String S3data1=flowfile.getAttribute("jsonData")
def apiResponse=new JsonSlurper().parseText(apiResult)
def S3data=new JsonSlurper().parseText(S3data1)
def result=apiResponse.data.collect{i->S3data.collectEntries{k,v->=="All"?i[0]:v}}
outputStream.write(result.toString().getBytes(StandardCharsets.UTF_8))}as StreamCallback)
session.transfer(flowfile,REL_SUCCESS)

ERROR LOGS getting this error in groovy script

ERROR [Timer-Driven Process Thread-9] o.a.nifi.processors.script.ExecuteScript ExecuteScript[id=75571200-41b6-3e1e-1a48-c2abb37207f1] Processing failed
org.apache.nifi.processor.exception.ProcessException: javax.script.ScriptException: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script5192.groovy: 22: Unexpected input: '(' @ line 22, column 23.
   flowfile=session.write(flowfile,{inputStream,outputStream->
                         ^

1 error

    at org.apache.nifi.processors.script.ExecuteScript.onTrigger(ExecuteScript.java:247)
    at org.apache.nifi.controller.StandardProcessorNode.onTrigger(StandardProcessorNode.java:1357)
    at org.apache.nifi.controller.tasks.ConnectableTask.invoke(ConnectableTask.java:246)
    at org.apache.nifi.controller.scheduling.TimerDrivenSchedulingAgent$1.run(TimerDrivenSchedulingAgent.java:102)
    at org.apache.nifi.engine.FlowEngine$2.run(FlowEngine.java:110)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:750)
Caused by: javax.script.ScriptException: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script5192.groovy: 22: Unexpected input: '(' @ line 22, column 23.
   flowfile=session.write(flowfile,{inputStream,outputStream->
                         ^

1 error

    at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:158)
    at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:264)
    at org.apache.nifi.script.impl.GroovyScriptRunner.run(GroovyScriptRunner.java:51)
    at org.apache.nifi.processors.script.ExecuteScript.onTrigger(ExecuteScript.java:230)
    ... 11 common frames omitted
Caused by: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script5192.groovy: 22: Unexpected input: '(' @ line 22, column 23.
   flowfile=session.write(flowfile,{inputStream,outputStream->
                         ^

1 error

    at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:292)
    at org.codehaus.groovy.control.ErrorCollector.addFatalError(ErrorCollector.java:148)
    at org.apache.groovy.parser.antlr4.AstBuilder.collectSyntaxError(AstBuilder.java:4321)
    at org.apache.groovy.parser.antlr4.AstBuilder.access$000(AstBuilder.java:176)
    at org.apache.groovy.parser.antlr4.AstBuilder$1.syntaxError(AstBuilder.java:4332)
    at groovyjarjarantlr4.v4.runtime.ProxyErrorListener.syntaxError(ProxyErrorListener.java:44)
    at groovyjarjarantlr4.v4.runtime.Parser.notifyErrorListeners(Parser.java:543)
    at groovyjarjarantlr4.v4.runtime.DefaultErrorStrategy.notifyErrorListeners(DefaultErrorStrategy.java:154)
    at org.apache.groovy.parser.antlr4.internal.DescriptiveErrorStrategy.reportInputMismatch(DescriptiveErrorStrategy.java:103)
    at org.apache.groovy.parser.antlr4.internal.DescriptiveErrorStrategy.recover(DescriptiveErrorStrategy.java:55)
    at org.apache.groovy.parser.antlr4.internal.DescriptiveErrorStrategy.recoverInline(DescriptiveErrorStrategy.java:68)
    at groovyjarjarantlr4.v4.runtime.Parser.match(Parser.java:213)
    at org.apache.groovy.parser.antlr4.GroovyParser.compilationUnit(GroovyParser.java:362)
    at org.apache.groovy.parser.antlr4.AstBuilder.buildCST(AstBuilder.java:250)
    at org.apache.groovy.parser.antlr4.AstBuilder.buildCST(AstBuilder.java:228)
    at org.apache.groovy.parser.antlr4.AstBuilder.buildAST(AstBuilder.java:269)
    at org.apache.groovy.parser.antlr4.Antlr4ParserPlugin.buildAST(Antlr4ParserPlugin.java:58)
    at org.codehaus.groovy.control.SourceUnit.buildAST(SourceUnit.java:256)
    at java.util.Iterator.forEachRemaining(Iterator.java:116)
    at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
    at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:580)
    at org.codehaus.groovy.control.CompilationUnit.buildASTs(CompilationUnit.java:666)
    at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:632)
    at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:389)
    at groovy.lang.GroovyClassLoader.lambda$parseClass$3(GroovyClassLoader.java:332)
    at org.codehaus.groovy.runtime.memoize.StampedCommonCache.compute(StampedCommonCache.java:163)
    at org.codehaus.groovy.runtime.memoize.StampedCommonCache.getAndPut(StampedCommonCache.java:154)
    at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:330)
    at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:314)
    at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:257)
    at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.getScriptClass(GroovyScriptEngineImpl.java:336)
    at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:153)
    ... 14 common frames omitted
2023-05-30 10:45:23,299 INFO [NiFi Web Server-757] o.a.n.c.s.StandardProcessScheduler Stopping ExecuteScript[id=75571200-41b6-3e1e-1a48-c2abb37207f1]
2023-05-30 10:45:23,299 INFO [NiFi Web Server-757] o.a.n.controller.StandardProcessorNode Stopping processor: ExecuteScript[id=75571200-41b6-3e1e-1a48-c2abb37207f1]
2023-05-30 10:45:23,299 INFO [Timer-Driven Process Thread-2] o.a.n.c.s.TimerDrivenSchedulingAgent Stopped scheduling ExecuteScript[id=75571200-41b6-3e1e-1a48-c2abb37207f1] to run
2023-05-30 10:45:23,300 INFO [Timer-Driven Process Thread-2] o.a.n.controller.StandardProcessorNode ExecuteScript[id=75571200-41b6-3e1e-1a48-c2abb37207f1] has completely stopped. Completing any associated Futures.
2023-05-30 10:45:24,077 INFO [Flow Service Tasks Thread-1] o.a.nifi.controller.StandardFlowService Saved flow controller org.apache.nifi.controller.FlowController@3873e106 // Another save pending = false
2023-05-30 10:45:25,289 INFO [pool-7-thread-1] o.a.n.c.r.WriteAheadFlowFileRepository Initiating checkpoint of FlowFile Repository
2023-05-30 10:45:25,289 INFO [pool-7-thread-1] o.a.n.c.r.WriteAheadFlowFileRepository Successfully checkpointed FlowFile Repository with 1 records in 0 milliseconds

**data in response attribute ** same data is in flowfile as well response

{"status":"success","data":[[446136,0],[446151,0],[446165,0],[446176,0],[446207,0],[446700,0],[446721,0],[447592,0],[447647,0],[447659,0],[450478,0],[451060,0],[452119,0],[453617,0],[454331,0],[454720,0],[454747,0],[454749,0],[454880,0],[455449,0],[455472,0],[455474,0],[455485,0],[455543,0],[455595,0],[455874,0],[455883,0],[455890,0],[456212,0],[456454,0],[446137,0],[446145,0],[446166,0],[446724,0],[446808,0],[449133,0],[450483,0],[451056,0],[454339,0],[456131,0],[456137,0],[456222,0],[446138,0],[446156,0],[446191,0],[446710,0],[446729,0],[446787,0],[446836,0],[449134,0],[450482,0],[451054,0],[453522,0],[453525,0],[454358,0],[455608,0],[455885,0],[446139,0],[446168,0],[446193,0],[446210,0],[447601,0],[448978,0],[449053,0],[452164,0],[453477,0],[453483,0],[453495,0],[453527,0],[453531,0],[454356,0],[454413,0],[455433,0],[455469,0],[456204,0],[456230,0],[446140,0],[446169,0],[446194,0],[446211,0],[446711,0],[446823,0],[447596,0],[450675,0],[452163,0],[452645,0],[453532,0],[454359,0],[454411,0],[455432,0],[455457,0],[455470,0],[455876,0],[456202,0],[456207,0],[456231,0],[456259,0],[446141,0],[446148,0],[446157,0],[446171,0],[446196,0],[446213,0],[446765,0],[446824,0],[448866,0],[448989,0],[450676,0],[452646,0],[452982,0],[453538,0],[454360,0],[454414,0],[454748,0],[455438,0],[455610,0],[456234,0],[446142,0],[446158,0],[446197,0],[449132,0],[450694,0],[451301,0],[451310,0],[451362,0],[451372,0],[451377,0],[451389,0],[451421,0],[453034,0],[453043,0],[453523,0],[453534,0],[454314,0],[454361,0],[454750,0],[455444,0],[455611,0],[456235,0],[446143,0],[446161,0],[446201,0],[446736,0],[446738,0],[446742,0],[450688,0],[450689,0],[450699,0],[451359,0],[451386,0],[451399,0],[451422,0],[452634,0],[452906,0],[453005,0],[453016,0],[453064,0],[453157,0],[454105,0],[454260,0],[454289,0],[454297,0],[454315,0],[454317,0],[454321,0],[454368,0],[454387,0],[454388,0],[454391,0],[454392,0],[454394,0],[454397,0],[454399,0],[454412,0],[454419,0],[454421,0],[454424,0],[454425,0],[454426,0],[454431,0],[454432,0],[454436,0],[454863,0],[454869,0],[455445,0],[455455,0],[455473,0],[455487,0],[455505,0],[455591,0],[455620,0],[456122,0],[456201,0],[456210,0],[446144,0],[446734,0],[446815,0],[446843,0],[447597,0],[449138,0],[450472,0],[451057,0],[453514,0],[454375,0],[455461,0],[455462,0],[455618,0],[455872,0],[455891,0],[456140,0],[456182,0],[446146,0],[446167,0],[446184,0],[446209,0],[446703,0],[447594,0],[449051,0],[453627,0],[454344,0],[456197,0],[456245,0],[456251,0],[446147,0],[446170,0],[446195,0],[446212,0],[446708,0],[446763,0],[446821,0],[453526,0],[453580,0],[453583,0],[454352,0],[454410,0],[454427,0],[455481,0],[455609,0],[455892,0],[456208,0],[456232,0],[456242,0],[446149,0],[446162,0],[446172,0],[446204,0],[446716,0],[446733,0],[446778,0],[447650,0],[449137,0],[450474,0],[450698,0],[452116,0],[452121,0],[453467,0],[454372,0],[455483,0],[455590,0],[455615,0],[455871,0],[455887,0],[446150,0],[450693,0],[451300,0],[451313,0],[451363,0],[451369,0],[451379,0],[451400,0],[451420,0],[453564,0],[453612,0],[453628,0],[454328,0],[454881,0],[455587,0],[455594,0],[456264,0],[446152,0],[446208,0],[446215,0],[446735,0],[446743,0],[446744,0],[450370,0],[450377,0],[450390,0],[450391,0],[451331,0],[451401,0],[451414,0],[451424,0],[451425,0],[452672,0],[452675,0],[452678,0],[452987,0],[452994,0],[453001,0],[453012,0],[453024,0],[453044,0],[453194,0],[453201,0],[453204,0],[453694,0],[454300,0],[454301,0],[454322,0],[454335,0],[454402,0],[454404,0],[454753,0],[454862,0],[455434,0],[455452,0],[455495,0],[455496,0],[455497,0],[455498,0],[455499,0],[455500,0],[455501,0],[455502,0],[455503,0],[455504,0],[455598,0],[455859,0],[455877,0],[456127,0],[456184,0],[456191,0],[456205,0],[456214,0],[456239,0],[446153,0],[446179,0],[446216,0],[446793,0],[447593,0],[448864,0],[448985,0],[450674,0],[450684,0],[453516,0],[453626,0],[454336,0],[454429,0],[454680,0],[455436,0],[455478,0],[455588,0],[455599,0],[456195,0],[456215,0],[456225,0],[456240,0],[446154,0],[446702,0],[446723,0],[446759,0],[446770,0],[446782,0],[447661,0],[450479,0],[450695,0],[454338,0],[454440,0],[455589,0],[455600,0],[455886,0],[456188,0],[446155,0],[446707,0],[446726,0],[446772,0],[446784,0],[446833,0],[447663,0],[450481,0],[450696,0],[454351,0],[455460,0],[455875,0],[456138,0],[456183,0],[456185,0],[446159,0],[446200,0],[446800,0],[446826,0],[447598,0],[448867,0],[449052,0],[450677,0],[452647,0],[453197,0],[453485,0],[453529,0],[454320,0],[454365,0],[454408,0],[455613,0],[456236,0],[456243,0],[446160,0],[446214,0],[446827,0],[446841,0],[447648,0],[448868,0],[449054,0],[450678,0],[453528,0],[453562,0],[454367,0],[455480,0],[455486,0],[455545,0],[455622,0],[456199,0],[456219,0],[446163,0],[446717,0],[446803,0],[446829,0],[446831,0],[447643,0],[454333,0],[454719,0],[456112,0],[456218,0],[456238,0],[456450,0],[446164,0],[446175,0],[446206,0],[446699,0],[446720,0],[446768,0],[446806,0],[447591,0],[448873,0],[449130,0],[450477,0],[451059,0],[452110,0],[452633,0],[452988,0],[452989,0],[452991,0],[453014,0],[453015,0],[453018,0],[453027,0],[453028,0],[453554,0],[453569,0],[454307,0],[454330,0],[454398,0],[454406,0],[454422,0],[454430,0],[455453,0],[455464,0],[456244,0],[456250,0],[446173,0],[446697,0],[446718,0],[446791,0],[446816,0],[447645,0],[448945,0],[452118,0],[453515,0],[454327,0],[455592,0],[456194,0],[456211,0],[446174,0],[446698,0],[446719,0],[446757,0],[446767,0],[446780,0],[446805,0],[447646,0],[448984,0],[449136,0],[450476,0],[451058,0],[452115,0],[452120,0],[453613,0],[454329,0],[454428,0],[454434,0],[454435,0],[454438,0],[454751,0],[454859,0],[455459,0],[455471,0],[455482,0],[455484,0],[455510,0],[455546,0],[455586,0],[455593,0],[455862,0],[455863,0],[455882,0],[456134,0],[456221,0],[456223,0],[446177,0],[446701,0],[446761,0],[446792,0],[446817,0],[452990,0],[453484,0],[454332,0],[455442,0],[455596,0],[455864,0],[456111,0],[446178,0],[451307,0],[451323,0],[451358,0],[451367,0],[451383,0],[451402,0],[451406,0],[451417,0],[451428,0],[452679,0],[453007,0],[453037,0],[453563,0],[453576,0],[453624,0],[454334,0],[455030,0],[455597,0],[456107,0],[456113,0],[456213,0],[456224,0],[456258,0],[456262,0],[446180,0],[448869,0],[448986,0],[450692,0],[451303,0],[451314,0],[451364,0],[451370,0],[451380,0],[451394,0],[451419,0],[452992,0],[453000,0],[453017,0],[453029,0],[453033,0],[453195,0],[453517,0],[453559,0],[454035,0],[454304,0],[454340,0],[454379,0],[454389,0],[454420,0],[455454,0],[455467,0],[455866,0],[456209,0],[446181,0],[446217,0],[448870,0],[448987,0],[450369,0],[450681,0],[451324,0],[451381,0],[451388,0],[451410,0],[451429,0],[452676,0],[453021,0],[453030,0],[453038,0],[453556,0],[454029,0],[454341,0],[454396,0],[455466,0],[455581,0],[455582,0],[456091,0],[456196,0],[446182,0],[448871,0],[450690,0],[451306,0],[451309,0],[451365,0],[451371,0],[451384,0],[451396,0],[452086,0],[452984,0],[453032,0],[453518,0],[453571,0],[454025,0],[454033,0],[454106,0],[454298,0],[454342,0],[454393,0],[454721,0],[454858,0],[454860,0],[455450,0],[455601,0],[456129,0],[456179,0],[456263,0],[456451,0],[456453,0],[446183,0],[446794,0],[446818,0],[448865,0],[449050,0],[453519,0],[454343,0],[454679,0],[455440,0],[455477,0],[455544,0],[455602,0],[455867,0],[455900,0],[456177,0],[456190,0],[456226,0],[446185,0],[446704,0],[446762,0],[446796,0],[446819,0],[454347,0],[455435,0],[455603,0],[455868,0],[456115,0],[456227,0],[446186,0],[447640,0],[450375,0],[451267,0],[451305,0],[451325,0],[451382,0],[451391,0],[451413,0],[451423,0],[452681,0],[453025,0],[453041,0],[453045,0],[453520,0],[453558,0],[453570,0],[454302,0],[454308,0],[454346,0],[454418,0],[455437,0],[455463,0],[455583,0],[456193,0],[456241,0],[456261,0],[446187,0],[450376,0],[451304,0],[451327,0],[451376,0],[451392,0],[451409,0],[453008,0],[453521,0],[453555,0],[454303,0],[454348,0],[454384,0],[454755,0],[454861,0],[455468,0],[455621,0],[456189,0],[456216,0],[446188,0],[446737,0],[446739,0],[446740,0],[446741,0],[446745,0],[450680,0],[450691,0],[451299,0],[451312,0],[451360,0],[451397,0],[451418,0],[452983,0],[452995,0],[453023,0],[453046,0],[453579,0],[454026,0],[454310,0],[454313,0],[454376,0],[454390,0],[454395,0],[454437,0],[455605,0],[455884,0],[455894,0],[456116,0],[456228,0],[446189,0],[446706,0],[446797,0],[446820,0],[447644,0],[453209,0],[454350,0],[455584,0],[455619,0],[456217,0],[456246,0],[456252,0],[446190,0],[446705,0],[446725,0],[446771,0],[446783,0],[446795,0],[446832,0],[447595,0],[447662,0],[448988,0],[450480,0],[452964,0],[453196,0],[453530,0],[454349,0],[455446,0],[455606,0],[456229,0],[446192,0],[446709,0],[446764,0],[446798,0],[446822,0],[454299,0],[454355,0],[454681,0],[455439,0],[456119,0],[446198,0],[451302,0],[451328,0],[451368,0],[451378,0],[451403,0],[451407,0],[451411,0],[452680,0],[452997,0],[452999,0],[453011,0],[453019,0],[453039,0],[453557,0],[453568,0],[453573,0],[453581,0],[454041,0],[454306,0],[454316,0],[454363,0],[454407,0],[454409,0],[455431,0],[455456,0],[455476,0],[456187,0],[456198,0],[456200,0],[456203,0],[456206,0],[446199,0],[446202,0],[446715,0],[446766,0],[446802,0],[446828,0],[454371,0],[455441,0],[455614,0],[456449,0],[446203,0],[447641,0],[450484,0],[451292,0],[451329,0],[451356,0],[451366,0],[451393,0],[451404,0],[451415,0],[451426,0],[452636,0],[452671,0],[452674,0],[452682,0],[452986,0],[452998,0],[453009,0],[453020,0],[453035,0],[453042,0],[453561,0],[453567,0],[453572,0],[453585,0],[454311,0],[454370,0],[454417,0],[454752,0],[455458,0],[455479,0],[455493,0],[455901,0],[456106,0],[456108,0],[456128,0],[456220,0],[456237,0],[456248,0],[456254,0],[456260,0],[456419,0],[456456,0],[446205,0],[447642,0],[451293,0],[451311,0],[451330,0],[451357,0],[451387,0],[451398,0],[451405,0],[451416,0],[451427,0],[452635,0],[452673,0],[453004,0],[453006,0],[453013,0],[453022,0],[453026,0],[453036,0],[453203,0],[453577,0],[453578,0],[454374,0],[454682,0],[454870,0],[455430,0],[455475,0],[455616,0],[456109,0],[456176,0],[456192,0],[456249,0],[456255,0],[446712,0],[446730,0],[446775,0],[446788,0],[446811,0],[446837,0],[449135,0],[450471,0],[452162,0],[452974,0],[453478,0],[454362,0],[455869,0],[456136,0],[446713,0],[446801,0],[446825,0],[446830,0],[452117,0],[453486,0],[453533,0],[454364,0],[455443,0],[455612,0],[456120,0],[446714,0],[446732,0],[446777,0],[446790,0],[446813,0],[446839,0],[447649,0],[450473,0],[450685,0],[451061,0],[453524,0],[454369,0],[455488,0],[455490,0],[455861,0],[455870,0],[456126,0],[456139,0],[456452,0],[446722,0],[446758,0],[446769,0],[446781,0],[446807,0],[447660,0],[448874,0],[452112,0],[452113,0],[454337,0],[455865,0],[455889,0],[456114,0],[446727,0],[446773,0],[446785,0],[446809,0],[446834,0],[449131,0],[450977,0],[451055,0],[454353,0],[455857,0],[456117,0],[456181,0],[456233,0],[456247,0],[456253,0],[446728,0],[446774,0],[446786,0],[446810,0],[446835,0],[452686,0],[452963,0],[454357,0],[454439,0],[454754,0],[455489,0],[455860,0],[446731,0],[446776,0],[446789,0],[446812,0],[446838,0],[449139,0],[452114,0],[452973,0],[454366,0],[455856,0],[456121,0],[446753,0],[446754,0],[446755,0],[446756,0],[448872,0],[450462,0],[452161,0],[453074,0],[454326,0],[454377,0],[455465,0],[456110,0],[446779,0],[446814,0],[446840,0],[446842,0],[447599,0],[447600,0],[447651,0],[447664,0],[448863,0],[448990,0],[450475,0],[450697,0],[454373,0],[454423,0],[454433,0],[455617,0],[455858,0],[446804,0],[449200,0],[450373,0],[450374,0],[450367,0],[450368,0],[450700,0],[450702,0],[451361,0],[451385,0],[451395,0],[451885,0],[452087,0],[452985,0],[452996,0],[453031,0],[453535,0],[453536,0],[453560,0],[454028,0],[454034,0],[454305,0],[454354,0],[454882,0],[455031,0],[455451,0],[455491,0],[455492,0],[455494,0],[455585,0],[455607,0],[455855,0],[455873,0],[455888,0],[456105,0],[456118,0],[456125,0],[456130,0],[456180,0],[456455,0],[451308,0],[451326,0],[451375,0],[451390,0],[451408,0],[451412,0],[452993,0],[453010,0],[453040,0],[454309,0],[454312,0],[454345,0],[455604,0],[452677,0],[452683,0],[452962,0],[453065,0],[453158,0],[453202,0],[453582,0],[452975,0],[453152,0],[453181,0],[453182,0],[453206,0],[453565,0],[453566,0],[453574,0],[453575,0],[453584,0],[453618,0],[453623,0],[454675,0],[230500,1],[230501,1],[230502,1],[230503,1],[230504,1],[236489,1],[236490,1],[236492,1],[236493,1],[236494,1],[236495,1],[236496,1],[236497,1],[236498,1],[236499,1],[236500,1],[236501,1],[236502,1],[236503,1],[236504,1],[236505,1],[236506,1],[236507,1],[236508,1],[236509,1],[236510,1],[236511,1],[236512,1],[236513,1],[236514,1],[236515,1],[236516,1],[236517,1],[236518,1],[236519,1],[236520,1],[236521,1],[236522,1],[236523,1],[236524,1],[236525,1],[236526,1],[236527,1],[236528,1],[236529,1],[236530,1],[236531,1],[236532,1],[236533,1],[236534,1],[236535,1],[236536,1],[236537,1],[236538,1],[236539,1],[236540,1],[236541,1],[236542,1],[236543,1],[236544,1],[236545,1],[236546,1],[236547,1],[236548,1],[236549,1],[236550,1],[236551,1],[236552,1],[236553,1],[236554,1],[236555,1],[236556,1],[236557,1],[236558,1],[236559,1],[236560,1],[236561,1],[236562,1],[236563,1],[236564,1],[236565,1],[236566,1],[236567,1],[236568,1],[236569,1],[236570,1],[236571,1],[236572,1],[236573,1],[236574,1],[236575,1],[236576,1],[236577,1],[236578,1],[236579,1],[236580,1],[236581,1],[236582,1],[236583,1],[236584,1],[236585,1],[236586,1],[236587,1],[236588,1],[236589,1],[236590,1],[236591,1],[236592,1],[236593,1],[236594,1],[236595,1],[236596,1],[236597,1],[236598,1],[236599,1],[236600,1],[236601,1],[236602,1],[236603,1],[236604,1],[236605,1],[236606,1],[236607,1],[236608,1],[236609,1],[236610,1],[236611,1],[236612,1],[236613,1],[236614,1],[236615,1],[236616,1],[236617,1],[236618,1],[236619,1],[236620,1],[236621,1],[236622,1],[236623,1],[236624,1],[236625,1],[236626,1],[236627,1],[236628,1],[236629,1],[236630,1],[236631,1],[236632,1],[236633,1],[236634,1],[236635,1],[236636,1],[236637,1],[236638,1],[236639,1],[236640,1],[236641,1],[236642,1],[236643,1],[236644,1],[236645,1],[236646,1],[236647,1],[236648,1],[236649,1],[236650,1],[236651,1],[236652,1],[236653,1],[236654,1],[236655,1],[236656,1],[236657,1],[236658,1],[236659,1],[236660,1],[236661,1],[236662,1],[236663,1],[236664,1],[236665,1],[236666,1],[236667,1],[236668,1],[236669,1],[236670,1],[236671,1],[236672,1],[236673,1],[236674,1],[236675,1],[236676,1],[236677,1],[236678,1],[236679,1],[236680,1],[236681,1],[236682,1],[236683,1],[236684,1],[236685,1],[236686,1],[236687,1],[236688,1],[236689,1],[236690,1],[236691,1],[236692,1],[236693,1],[236694,1],[236695,1],[236696,1],[236697,1],[236698,1],[236699,1],[236700,1],[236701,1],[236702,1],[236703,1],[236704,1],[236705,1],[236706,1],[236707,1],[236708,1],[236709,1],[236710,1],[236711,1],[236712,1],[236713,1],[236714,1],[236715,1],[236716,1],[236717,1],[236718,1],[236719,1],[236720,1],[236721,1],[236722,1],[236723,1],[236724,1],[236725,1],[236726,1],[236727,1],[236728,1],[236729,1],[236730,1],[236731,1],[236732,1],[236733,1],[236734,1],[236735,1],[236736,1],[236737,1],[236738,1],[236739,1],[236740,1],[236741,1],[236742,1],[236743,1],[236744,1],[236745,1],[236746,1],[236747,1],[236748,1],[236749,1],[236750,1],[236751,1],[236752,1],[236753,1],[236754,1],[236755,1],[236756,1],[236757,1],[236758,1],[236759,1],[236760,1],[236761,1],[236762,1],[236763,1],[236764,1],[236765,1],[236766,1],[236767,1],[236768,1],[236769,1],[236770,1],[236771,1],[236772,1],[236773,1],[236774,1],[236775,1],[236776,1],[236777,1],[236778,1],[236779,1],[236780,1],[236781,1],[236782,1],[236783,1],[236784,1],[236785,1],[236786,1],[236787,1],[236788,1],[236789,1],[236790,1],[236791,1],[236792,1],[236793,1],[236794,1],[236795,1],[236796,1],[236797,1],[236798,1],[236799,1],[236800,1],[236801,1],[236802,1],[236803,1],[236804,1],[236805,1],[236806,1],[236807,1],[236808,1],[236809,1],[236810,1],[236811,1],[236812,1],[236813,1],[236814,1],[236815,1],[236816,1],[236817,1],[236818,1],[236819,1],[236820,1],[236821,1],[236822,1],[236823,1],[236824,1],[236825,1],[236826,1],[236827,1],[236828,1],[236829,1],[236830,1],[236831,1],[236832,1],[236833,1],[236834,1],[236835,1],[236836,1],[236837,1],[236838,1],[236839,1],[236840,1],[236841,1],[236842,1],[236843,1],[236844,1],[236845,1],[236846,1],[236847,1],[236848,1],[236849,1],[236850,1],[236851,1],[236852,1],[236853,1],[236854,1],[236855,1],[236856,1],[236857,1],[236858,1],[236859,1],[236860,1],[236861,1],[236862,1],[236863,1],[236864,1],[236865,1],[236866,1],[236867,1],[236868,1],[236869,1],[236870,1],[236871,1],[236872,1],[236873,1],[236874,1],[236875,1],[236876,1],[236877,1],[236878,1],[236879,1],[236880,1],[236881,1],[236882,1],[236883,1],[236884,1],[236885,1],[236886,1],[236887,1],[236888,1],[236889,1],[236890,1],[236891,1],[236892,1],[236893,1],[236894,1],[236895,1],[236896,1],[236897,1],[236898,1],[236899,1],[236900,1],[236901,1],[236902,1],[236903,1],[236904,1],[236905,1],[236906,1],[236907,1],[236908,1],[236909,1],[236910,1],[236911,1],[236912,1],[236913,1],[236914,1],[236915,1],[236916,1],[236917,1],[236918,1],[236919,1],[236920,1],[236921,1],[236922,1],[236923,1],[236924,1],[236925,1],[236926,1],[236927,1],[236928,1],[236929,1],[236930,1],[236931,1],[236932,1],[236933,1],[236934,1],[236935,1],[236936,1],[236937,1],[237010,1],[237082,1]]}

Adriaan
  • 17,741
  • 7
  • 42
  • 75
dash
  • 35
  • 5
  • error is saying that script can't be compiled. better to switch to "ExecuteGroovyScript" processor. It compiles script just after save, gives you correct line numbers on error, and it works faster. – daggett May 29 '23 at 18:37
  • still getting error :( – dash May 29 '23 at 18:49
  • right. but now you should get correct line number. and i bet there is an incorrect "space" character in your code. usually it appears after copy-pasting code from some sites... – daggett May 29 '23 at 18:52
  • @daggett Is there anyway we can apply some logic in java using map? because it was reading for ecmacscript but not using ecmascripts map or fromEntries function, hence I had to shift to groovy. But ecma in Nifi actually uses JAVA METHODS. So if we can apply same logic in java – dash May 29 '23 at 18:54
  • please update your question with new error message then someone could help. `apply some logic in java using map` - groovy based on java - i can't understand this request. – daggett May 29 '23 at 18:57
  • Please don't make more work for other people by vandalizing your posts. By posting on the Stack Exchange network, you've granted a non-revocable right, under the [CC BY-SA 4.0 license](https://creativecommons.org/licenses/by-sa/4.0/), for Stack Exchange to distribute that content (i.e. regardless of your future choices). By Stack Exchange policy, the non-vandalized version of the post is the one which is distributed. Thus, any vandalism will be reverted. If you want to know more about deleting a post please see: [How does deleting work?](https://meta.stackexchange.com/q/5221) – Adriaan May 30 '23 at 10:15

1 Answers1

0

this piece of code is absolutely incorrect and breaking compilations step of your script

collectEntries{k,v->=="All"?i[0]:v}

BTW. variable inJson never been used in your code so you don't need following lines:

def content=IOUtils.toString(inputStream,StandardCharsets.UTF_8)
def inJson=new JsonSlurper().parseText(content)

the following code is not producing json ( I just guess you need a json )

result.toString()

to get json you could replace it with:

new JsonBuilder(result).toString()
daggett
  • 26,404
  • 3
  • 40
  • 56