Mike,
I'm looking into whether this is possible with UpdateRecord or not.
For the article you mentioned, the OP wanted to nest values into a
record that didn't exist in the input. Not sure if that's technically
the same as your case but could be.
In the meantime this Jolt spec should work with JoltTransformRecord
(you can go directly from CSV to nested JSON without having to convert
first):
[
{
"operation": "shift",
"spec": {
"*": "user.&"
}
}
]
Regards,
Matt
On Mon, Dec 3, 2018 at 11:37 AM Mike Thomsen <[email protected]> wrote:
>
> Looks like I missed this:
>
> https://community.hortonworks.com/questions/212877/want-to-convert-csv-to-nested-json-using-nifi.html
>
> I'll get crackin on Jolt since that seems to be the best answer at the moment.
>
> On Mon, Dec 3, 2018 at 11:24 AM Mike Thomsen <[email protected]> wrote:
>>
>> We have a need to be able to take a CSV file and convert it into a nested
>> JSON structure. I did a simple test with GenerateFlowFile and a few
>> ConvertRecord processors. Test was:
>>
>> GenerateFlowFile (JSON) -> ConvertRecord (JSON in, CSV out) -> ConvertRecord
>> (CSV in, JSON out) and it threw an exception in the last ConvertRecord when
>> it went from something that looked like this:
>>
>> user
>> "MapRecord[{name=Test User, [email protected]}]"
>>
>> Sample data and schema:
>>
>> {
>> "user": {
>> "name": "Test User",
>> "email": "[email protected]"
>> }
>> }
>>
>> {
>> "type": "record",
>> "name": "User",
>> "fields": [
>> {
>> "name": "user",
>> "type": {
>> "name": "UserDetails",
>> "type": "record",
>> "fields": [
>> {
>> "name": "name",
>> "type": "string"
>> },
>> {
>> "name": "email",
>> "type": "string"
>> }
>> ]
>> }
>> }
>> ]
>> }
>>
>> Any ideas on how to do this? I honestly don't recall every seeing anyone try
>> to do this, and understand if the Record API needs a ticket or two to make
>> it happen. Just need to know if I'm missing something.
>>
>> Thanks,
>>
>> Mike