There’s something similar in Jira for JSON-to-JSON conversions:

https://issues.apache.org/jira/browse/NIFI-361

If that were implemented, you could hook an Attributes to JSON up to it and 
specify the transformation to un-flatten it.

From:  Jeroen Jacobs <[email protected]>
Reply-To:  <[email protected]>
Date:  Monday, February 1, 2016 at 6:47 PM
To:  "[email protected]" <[email protected]>
Subject:  Re: Nesting and AttributesToJSON

Maybe a possible suggestion to map attributes to JSON:



Can you add a property "JSONMapping" or something, where you can use JSON Path 
expressions to map FlowFile attributes to JSON attributes? It's just an idea...



Jeroen.



From: Jeroen Jacobs <[email protected]>
Sent: Tuesday, February 2, 2016 12:40 AM
To: [email protected]
Subject: Re: Nesting and AttributesToJSON
 
Hi,



To be honest, I have no idea. Is there any other way I can accomplish this task?



I was also looking for a workaround that allows me to set the content of the 
flowfile using expression language.


Maybe something like this:

{
    "card" : {

        "style" = "${card.style}"

         "url" = "${card.url}"

    }

}


But I can't seem to find a processor that allows this either. Quite 
frustrating, as it seems I need to ditch NiFi as a possible solution for my 
problem, and need to resort to custom scripting again.



Jeroen.



From: Jeremy Dyer <[email protected]>
Sent: Tuesday, February 2, 2016 12:14 AM
To: [email protected]
Subject: Re: Nesting and AttributesToJSON
 
Jeroen, 

AttributesToJSON currently does not support nested JSON and instead maps 
everything to a flat JSON object. The problem is a lot of NiFi attributes used 
the "something.else" syntax and it would be hard to determine what delimiter 
should indicate a nested JSON element. 

Right now you are going to get the result ...

{
 "card.style" = url

 "card.url" = http://mysite.com

}

Knowing about the "." limitation do you have ideas about how you would like to 
see this nesting occur?

Thanks,
Jeremy Dyer


On Mon, Feb 1, 2016 at 5:57 PM, Jeroen Jacobs <[email protected]> 
wrote:


Hi,



A very simple question: How do I need to arrange my attributes to get the 
following JSON file:



{

    "card": {

        "style" : "url"

        "url": "http://mysite.com";

    }

}



I tried it by creating two attributes:



card.style = url

card.url = http://mysite.com



But no matter how I try to use AttributesToJSON, I don't get the desired 
result. I tried to pass "card" and "card.*" as arguments to Attributes List, 
but they don't have the desired result. 



And I don't like to repeat myself, but the documentation doesn't mention it 
either...



Kind regards,

Jeroen


Reply via email to