You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@nifi.apache.org by Jeroen Jacobs <je...@headincloud.be> on 2016/02/01 23:57:05 UTC

Nesting and AttributesToJSON

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

Re: Nesting and AttributesToJSON

Posted by Bryan Bende <bb...@gmail.com>.
Hi Jeroen,

ReplaceText will let you set the content of the FlowFile using expression
language like you described.

I believe this template - ConvertCsvToJson [1] - shows something similar to
what you are trying to do. Let us know if this helps.

-Bryan

[1]
https://cwiki.apache.org/confluence/download/attachments/57904847/CsvToJSON.xml?version=1&modificationDate=1442927496000&api=v2



On Mon, Feb 1, 2016 at 6:40 PM, Jeroen Jacobs <je...@headincloud.be>
wrote:

> 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 <jd...@gmail.com>
> *Sent:* Tuesday, February 2, 2016 12:14 AM
> *To:* users@nifi.apache.org
> *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 <
> jeroen.jacobs@headincloud.be> 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
>>
>
>

Re: Nesting and AttributesToJSON

Posted by Joe Witt <jo...@gmail.com>.
we were super hopeful to start the RC process today but still have a
few important reviews underway.  I'd guess any day it is feasible.
The big NIFI-259 (state management) is getting some very thorough
review/testing cycles on it (as it should).

Thanks
Joe

On Mon, Feb 1, 2016 at 9:15 PM, Jeroen Jacobs
<je...@headincloud.be> wrote:
> Hi Joe,
>
> I was able to solve it with ReplaceText, as suggested. So, I'm happy again for now ;-)
>
>
> The in-line script feature looks awesome indeed. Any estimate on the release date of 050?
>
>
> Kind regards,
>
>
> Jeroen.
>
>
>
> ________________________________________
> From: Joe Witt <jo...@gmail.com>
> Sent: Tuesday, February 2, 2016 3:01 AM
> To: users@nifi.apache.org
> Subject: Re: Nesting and AttributesToJSON
>
> Jeroen
>
> Definitely empathize with how frustrating it can be to have components
> which get you so close but not quite there.  Very happy to suggest
> that NIFI-210 (due for inclusion for the upcoming 050 release - in
> fact merging it in as we speak) will give you the ability to write
> scripts in-line in Groovy, Ruby, Javascript, Pythong (jython), and
> Lua.  That should help greatly with these sorts of cases where you
> know exactly what you want and could easily express it in a script but
> the framework can handle all the other fun pieces.  That script then
> interestingly enough forms a very powerful expression of requirement
> should the code need to be written in pure Java or otherwise later.
>
> Thanks
> Joe
>
> On Mon, Feb 1, 2016 at 6:50 PM, Matthew Burgess <ma...@gmail.com> wrote:
>> 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 <je...@headincloud.be>
>> Reply-To: <us...@nifi.apache.org>
>> Date: Monday, February 1, 2016 at 6:47 PM
>> To: "users@nifi.apache.org" <us...@nifi.apache.org>
>>
>> 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 <je...@headincloud.be>
>> Sent: Tuesday, February 2, 2016 12:40 AM
>> To: users@nifi.apache.org
>> 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 <jd...@gmail.com>
>> Sent: Tuesday, February 2, 2016 12:14 AM
>> To: users@nifi.apache.org
>> 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 <je...@headincloud.be>
>> 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
>>
>>

Re: Nesting and AttributesToJSON

Posted by Jeroen Jacobs <je...@headincloud.be>.
Hi Joe,

I was able to solve it with ReplaceText, as suggested. So, I'm happy again for now ;-)


The in-line script feature looks awesome indeed. Any estimate on the release date of 050?


Kind regards,
​

Jeroen.



________________________________________
From: Joe Witt <jo...@gmail.com>
Sent: Tuesday, February 2, 2016 3:01 AM
To: users@nifi.apache.org
Subject: Re: Nesting and AttributesToJSON

Jeroen

Definitely empathize with how frustrating it can be to have components
which get you so close but not quite there.  Very happy to suggest
that NIFI-210 (due for inclusion for the upcoming 050 release - in
fact merging it in as we speak) will give you the ability to write
scripts in-line in Groovy, Ruby, Javascript, Pythong (jython), and
Lua.  That should help greatly with these sorts of cases where you
know exactly what you want and could easily express it in a script but
the framework can handle all the other fun pieces.  That script then
interestingly enough forms a very powerful expression of requirement
should the code need to be written in pure Java or otherwise later.

Thanks
Joe

On Mon, Feb 1, 2016 at 6:50 PM, Matthew Burgess <ma...@gmail.com> wrote:
> 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 <je...@headincloud.be>
> Reply-To: <us...@nifi.apache.org>
> Date: Monday, February 1, 2016 at 6:47 PM
> To: "users@nifi.apache.org" <us...@nifi.apache.org>
>
> 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 <je...@headincloud.be>
> Sent: Tuesday, February 2, 2016 12:40 AM
> To: users@nifi.apache.org
> 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 <jd...@gmail.com>
> Sent: Tuesday, February 2, 2016 12:14 AM
> To: users@nifi.apache.org
> 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 <je...@headincloud.be>
> 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
>
>

Re: Nesting and AttributesToJSON

Posted by Joe Witt <jo...@gmail.com>.
Jeroen

Definitely empathize with how frustrating it can be to have components
which get you so close but not quite there.  Very happy to suggest
that NIFI-210 (due for inclusion for the upcoming 050 release - in
fact merging it in as we speak) will give you the ability to write
scripts in-line in Groovy, Ruby, Javascript, Pythong (jython), and
Lua.  That should help greatly with these sorts of cases where you
know exactly what you want and could easily express it in a script but
the framework can handle all the other fun pieces.  That script then
interestingly enough forms a very powerful expression of requirement
should the code need to be written in pure Java or otherwise later.

Thanks
Joe

On Mon, Feb 1, 2016 at 6:50 PM, Matthew Burgess <ma...@gmail.com> wrote:
> 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 <je...@headincloud.be>
> Reply-To: <us...@nifi.apache.org>
> Date: Monday, February 1, 2016 at 6:47 PM
> To: "users@nifi.apache.org" <us...@nifi.apache.org>
>
> 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 <je...@headincloud.be>
> Sent: Tuesday, February 2, 2016 12:40 AM
> To: users@nifi.apache.org
> 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 <jd...@gmail.com>
> Sent: Tuesday, February 2, 2016 12:14 AM
> To: users@nifi.apache.org
> 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 <je...@headincloud.be>
> 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
>
>

Re: Nesting and AttributesToJSON

Posted by Matthew Burgess <ma...@gmail.com>.
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 <je...@headincloud.be>
Reply-To:  <us...@nifi.apache.org>
Date:  Monday, February 1, 2016 at 6:47 PM
To:  "users@nifi.apache.org" <us...@nifi.apache.org>
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 <je...@headincloud.be>
Sent: Tuesday, February 2, 2016 12:40 AM
To: users@nifi.apache.org
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 <jd...@gmail.com>
Sent: Tuesday, February 2, 2016 12:14 AM
To: users@nifi.apache.org
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 <je...@headincloud.be> 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



Re: Nesting and AttributesToJSON

Posted by Jeroen Jacobs <je...@headincloud.be>.
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 <je...@headincloud.be>
Sent: Tuesday, February 2, 2016 12:40 AM
To: users@nifi.apache.org
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 <jd...@gmail.com>
Sent: Tuesday, February 2, 2016 12:14 AM
To: users@nifi.apache.org
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<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 <je...@headincloud.be>> 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


Re: Nesting and AttributesToJSON

Posted by Matthew Burgess <ma...@gmail.com>.
You can use ReplaceText for this, paste your JSON below into the Replacement Text attribute, leave the other defaults (to overwrite the entire text). I just tested this with your values and it looks good.

From:  Jeroen Jacobs <je...@headincloud.be>
Reply-To:  <us...@nifi.apache.org>
Date:  Monday, February 1, 2016 at 6:40 PM
To:  "users@nifi.apache.org" <us...@nifi.apache.org>
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 <jd...@gmail.com>
Sent: Tuesday, February 2, 2016 12:14 AM
To: users@nifi.apache.org
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 <je...@headincloud.be> 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



Re: Nesting and AttributesToJSON

Posted by Jeroen Jacobs <je...@headincloud.be>.
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 <jd...@gmail.com>
Sent: Tuesday, February 2, 2016 12:14 AM
To: users@nifi.apache.org
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<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 <je...@headincloud.be>> 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


Re: Nesting and AttributesToJSON

Posted by Jeremy Dyer <jd...@gmail.com>.
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 <je...@headincloud.be>
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
>