You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@nifi.apache.org by Mike Thomsen <mi...@gmail.com> on 2021/08/10 19:20:22 UTC
Re: Need help to create avro schema for arrays with tags
You'll probably want to go more like this:
{
"name": "objectDetails",
"type": {
"type": "array",
"items": {
"name": "AdditionalInfoRecord",
"type": "record",
"fields": [
{ "name": "name", "type": "string" },
{ "name": "value", "type": "string" }
]
}
}
}
That would go for a JSON like this:
"objectDetails": [
{ "name": "tag1", "value": "value1" }, //etc.
]
On Wed, Jul 28, 2021 at 8:17 AM Jens M. Kofoed <jm...@gmail.com> wrote:
>
> Dear community
>
> I'm struggling with transforming some xml data into a json format using an avro schema.
> The data which I can't get to work looks something like this:
> <object>
> <objectDetails>
> <additionalInfo name="tag1">value1</additionalInfo>
> <additionalInfo name="tag2">value2</additionalInfo>
> <additionalInfo name="tag3">value3</additionalInfo>
> </objectDetails>
> <objectIdentification>
> <objectId>1</objectId>
> <objectType>objType</objectType>
> </objectIdentification>
> </object>
>
> If I set the type for additionalInfo to array, I only gets the values. I tried to set the array items to a record. But I can't get the tag names.
>
> My goal is to get a json like this:
> "object" : {
> "objectDetails" : [
> { "additionalInfo" : "tag1", "value":"value1"}
> { "additionalInfo" : "tag2", "value":"value2"}
> { "additionalInfo" : "tag3", "value":"value3"}
> ],
> "objectIdentification" : {
> "objectId" : 1,
> "objectType" : " objType "
> }
> }
>
> or
>
> "object" : {
> "objectDetails" : {
> "additionalInfo" : [
> {"name":"tag1", "value":"value1"},
> { "name":"tag2", "value":"value2"},
> { "name":"tag3", "value":"value3"}
> ]
> },
> "objectIdentification" : {
> "objectId" : 1,
> "objectType" : " objType "
> }
> }
>
> Kind regards
> Jens M. Kofoed
>
>