Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

Use nested value from record as key in Kafka

avatar
Explorer

Hi guys,

I have some problem with public data on Kafka. I have record to public like this:

{
"name": "Jess",
"surname": "Stone",
 "data": {
"mail": "j.stone@gmail.com",
"class": "5",
  "address": {
  "country": "Brasil",
  "city": "Rio de Janeiro"
 }
},
"anotherData": {
"sex": "female",
"code": "1220"
}
}

I need set code value as key so I set it like 

Message Key Field sex
But it doesn't works, i think it is possible that it doesn't work because this value is nested-when I set for example name it works. Maybe you know how can I set these nested value from this record to Message Key Field? I tried something like this: anotherData.sex but it doesn't work too...
1 REPLY 1

avatar
Super Collaborator

Have you considered using EvaluateJSONPath to extract the value as a FlowFile attribute and then use that for your key when publishing to Kafka?