You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@nifi.apache.org by shweta <sh...@gmail.com> on 2016/02/03 15:19:00 UTC

Struggling with modification of JSON|AttributeToJSON

Hi All,

I have a sample JSON of following format.
{
"a":"1",
"b":"2",
"c":"3",
"d":"4"
}

I have two requirements. First is to split them into two jsons as
following:-
{
"a":"1",
"b":"2"
}

and
{
"c":"3",
"d":"4"
}


and my second requirement is to create a nested JSON as following

{"a":"1","info":{"a":"1","b":"2","c":"3","d":"4"}}

I have tried to use the combination of EvaluateJSONPath and AttributeToJSON
processor but that did not worked to get the desired output. Can someone
please help.

Regards,
Shweta



--
View this message in context: http://apache-nifi-developer-list.39713.n7.nabble.com/Struggling-with-modification-of-JSON-AttributeToJSON-tp7129.html
Sent from the Apache NiFi Developer List mailing list archive at Nabble.com.

Re: Struggling with modification of JSON|AttributeToJSON

Posted by Joe Percivall <jo...@yahoo.com.INVALID>.
Hello Shweta,

For requirement #1, check out the SplitJson processor. It should enable you to do what you need.

For requirement #2, currently AttributesToJSON can only create flat JSON objects. What you could do is use the ReplaceText processor "manually" do it. You'd leave the search query as the default one (it overwrites the entire content of the flowfile) and then create a replace query that utilizes EL to put the values of attributes where you need them.

Hope that helps,
Joe- - - - - - 
Joseph Percivall
linkedin.com/in/Percivall
e: joepercivall@yahoo.com




On Wednesday, February 3, 2016 10:10 AM, shweta <sh...@gmail.com> wrote:
Hi All,

I have a sample JSON of following format.
{
"a":"1",
"b":"2",
"c":"3",
"d":"4"
}

I have two requirements. First is to split them into two jsons as
following:-
{
"a":"1",
"b":"2"
}

and
{
"c":"3",
"d":"4"
}


and my second requirement is to create a nested JSON as following

{"a":"1","info":{"a":"1","b":"2","c":"3","d":"4"}}

I have tried to use the combination of EvaluateJSONPath and AttributeToJSON
processor but that did not worked to get the desired output. Can someone
please help.

Regards,
Shweta



--
View this message in context: http://apache-nifi-developer-list.39713.n7.nabble.com/Struggling-with-modification-of-JSON-AttributeToJSON-tp7129.html
Sent from the Apache NiFi Developer List mailing list archive at Nabble.com.