Re: Converting long string to JSON format.
That is a good idea, thanks. Is there any documentation on making a script that will work for this processor? (i.e. requirements if there are any for the script itself?) -- Sent from: http://apache-nifi-users-list.2361937.n4.nabble.com/
Re: Converting long string to JSON format.
I think you could accomplish this using ConvertRecord. For the Record Reader, use a CSVReader with the delimiter character set to |, and for the Record Writer, use a JsonRecordSetWriter. You may have to use a ScriptedRecordSetWriter to parse the key/value pair tokens out individually. Andy LoPresto alopre...@apache.org alopresto.apa...@gmail.com PGP Fingerprint: 70EC B3E5 98A6 5A3F D3C4 BACE 3C6E F65B 2F7D EF69 > On Nov 6, 2019, at 9:24 AM, Chandrashekhar Kotekar > wrote: > > I would prefer to write custom processor which will first convert those key > value pairs into Properties object and then map that object to POJO and use > json4s to convert pojo to JSON. > > Sent from my iPhone > >> On 6 Nov 2019, at 9:13 pm, Rivasa wrote: >> >> Hi, so I'm having a bit of trouble where I can't really figure out how to >> accomplish what I need, since i'm fairly new to NIFI in general. >> >> So I have a string in the following format: >> item1=value1|item2=value2|item3=value3|item4=value4... so on and so forth. >> >> What I would like to do is convert this into a valid JSON object of the >> format of: >> { >> "item1":"value1", >> "item2":"value2", >> "item3":"value3", >> "item4":"value4" >> ... >> etc >> } >> >> I think I need to use extract text or similar maybe? But I'm not exactly >> sure what to do. Could someone point me in the right direction? >> >> >> >> -- >> Sent from: http://apache-nifi-users-list.2361937.n4.nabble.com/
Re: Converting long string to JSON format.
I would prefer to write custom processor which will first convert those key value pairs into Properties object and then map that object to POJO and use json4s to convert pojo to JSON. Sent from my iPhone > On 6 Nov 2019, at 9:13 pm, Rivasa wrote: > > Hi, so I'm having a bit of trouble where I can't really figure out how to > accomplish what I need, since i'm fairly new to NIFI in general. > > So I have a string in the following format: > item1=value1|item2=value2|item3=value3|item4=value4... so on and so forth. > > What I would like to do is convert this into a valid JSON object of the > format of: > { > "item1":"value1", > "item2":"value2", > "item3":"value3", > "item4":"value4" > ... > etc > } > > I think I need to use extract text or similar maybe? But I'm not exactly > sure what to do. Could someone point me in the right direction? > > > > -- > Sent from: http://apache-nifi-users-list.2361937.n4.nabble.com/
Converting long string to JSON format.
Hi, so I'm having a bit of trouble where I can't really figure out how to accomplish what I need, since i'm fairly new to NIFI in general. So I have a string in the following format: item1=value1|item2=value2|item3=value3|item4=value4... so on and so forth. What I would like to do is convert this into a valid JSON object of the format of: { "item1":"value1", "item2":"value2", "item3":"value3", "item4":"value4" ... etc } I think I need to use extract text or similar maybe? But I'm not exactly sure what to do. Could someone point me in the right direction? -- Sent from: http://apache-nifi-users-list.2361937.n4.nabble.com/