Dweep,

Depending on how complex the content JSON is, you might be able to use
ReplaceText to smuggle the attributes into the text, but this can be
tricky as you need to match on the opening JSON and the rest, and then
replace it with the opening JSON, the attributes, then the rest in
order to preserve valid JSON.

You may also be able to use UpdateRecord to add fields to your
content, I believe if the Replacement Value Strategy property is set
to "Literal Value" you can use Expression Language which may be able
access flow file attributes.

An alternative is to use a scripted processor if you're comfortable
with a scripting language such as Groovy, as it can "slurp" JSON into
a Plain Old Groovy Object (POGO), then you can add fields and
serialize back out to JSON. I have a somewhat similar example here
[1].

Regards,
Matt

[1] 
http://funnifi.blogspot.com/2016/02/executescript-json-to-json-conversion.html

On Tue, May 19, 2020 at 10:46 AM Dweep Sharma <[email protected]> wrote:
>
> Hi All,
>
> Does anyone have a strategy to combine Attributes & Content into a single 
> Flowfile?
>
> AttributesToJson seems like the best way convert all attributes to content 
> -Json but I
>
> lose the original content.
>
> Basically, I have a HandleHTTPRequest Processor and headers and body must be 
> combined,
>
> currently Headers are stored as Attributes in a flowfile
>
> -Dweep
>
>
> ::DISCLAIMER::
> ----------------------------------------------------------------------------------------------------------------------------------------------------
>
> The contents of this e-mail and any attachments are confidential and intended 
> for the named recipient(s) only.E-mail transmission is not guaranteed to be 
> secure or error-free as information could be intercepted, corrupted,lost, 
> destroyed, arrive late or incomplete, or may contain viruses in transmission. 
> The e mail and its contents(with or without referred errors) shall therefore 
> not attach any liability on the originator or redBus.com. Views or opinions, 
> if any, presented in this email are solely those of the author and may not 
> necessarily reflect the views or opinions of redBus.com. Any form of 
> reproduction, dissemination, copying, disclosure, modification,distribution 
> and / or publication of this message without the prior written consent of 
> authorized representative of redbus.com is strictly prohibited. If you have 
> received this email in error please delete it and notify the sender 
> immediately.Before opening any email and/or attachments, please check them 
> for viruses and other defects.

Reply via email to