nifi-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Herssens <chris.herss...@gmail.com>
Subject Re: JoltTransformJSON with array of jsons
Date Thu, 12 Oct 2017 10:08:36 GMT
I tried this, but I get only one json back. Where each element has a array
of values. I need as result an  array of json. The transformation should be
done on each json.

Op 12 okt. 2017 12:01 p.m. schreef "Mark Rachelski" <mark@acommerce.asia>:

> Chris,
>
> This does not work because your Jolt Specification is saying you are
> looking for a top-level element called timestamp_start. Try something like
> this:
>
> [
>   {
>     "operation" : "shift",
>     "spec": {
>       "*": {
>       "timestamp_start" : "timestamp_start",
>       "timestamp_end" : "timestamp_end",
>       "custom_primitives" : {
>           "*": "&" }
>      }
>     }
>   }
> ]
>
> to allow for the array.
>
> Also, I recommend you don't develop your jolt specification inside NiFi...
> NiFi is the runtime processor.
>
> From a development environment just use this site: http://jolt-demo.
> appspot.com/#inception where you can paste in your starting document and
> specification to find a spec that does what you want.   Then after the spec
> works, you can put it into your JoltTransformJson processor.
>
> Mar.k
>
> On Thu, Oct 12, 2017 at 4:52 PM Chris Herssens <chris.herssens@gmail.com>
> wrote:
>
>> Hello Pierre,
>>
>> I want to flatten the json content.  How to I do this ?
>> Now  I use the chain DSL with jolt spec
>>
>> [
>>   {
>>     "operation" : "shift",
>>     "spec": {
>>       "timestamp_start" : "timestamp_start",
>>       "timestamp_end" : "timestamp_end",
>>       "custom_primitives" : {
>>           "*": "&" }
>>     }
>>   }
>> ]
>>
>> this doesn't work with an array of json only with a single json
>>
>> Regards,
>>
>> Chris
>>
>>
>>
>> On Thu, Oct 12, 2017 at 11:26 AM, Pierre Villard <
>> pierre.villard.fr@gmail.com> wrote:
>>
>>> Hi Chris,
>>>
>>> Yes it is.
>>>
>>> For example, if I want to add a field in all JSON of my array - I can do
>>> (with default DSL) :
>>>
>>> {
>>>   "*": {
>>>     "mynewfield":"mynewvalue"
>>>   }
>>> }
>>>
>>> I'm clearly not a Jolt expert, but others can help you if you're trying
>>> to do something more complex.
>>>
>>> Pierre
>>>
>>>
>>>
>>> 2017-10-12 11:04 GMT+02:00 Chris Herssens <chris.herssens@gmail.com>:
>>>
>>>> Hello,
>>>>
>>>> Is it possible to use the JoltTransformJson processor with an array of
>>>> jsons as input
>>>>
>>>> Regards,
>>>>
>>>> Chris
>>>>
>>>
>>>
>>

Mime
View raw message