Support Questions

Find answers, ask questions, and share your expertise
Announcements
Check out our newest addition to the community, the Cloudera Data Analytics (CDA) group hub.

Unmatched JSON keyname and table columnname

New Contributor

I am new to NiFi, and I am trying to put some data into a postgresql database. I am trying to do it with the ConvertJSONtoSQL processor, unfortunately the JSON keyname and the columename of the table having not the same names (for example keyname = ServiceGroup and columnname = service_group).

How can I map the key- and the columnname, so I can store the data in the tablename.

1 ACCEPTED SOLUTION

Rising Star

To change the key names of your JSON you can transform it with JOLT.

The Processor name calls JoltTransformJSON

 

In the property you can "Jolt Specification" you can insert following code, that would be change your key from ServiceGroup to service_group and afterwards you can send the flowfile to the sql processor..

 

[
  {
    "operation": "shift",
    "spec": {
      "ServiceGroup": "service_group",
      "*": "&"
    }
  }
]

 

View solution in original post

4 REPLIES 4

Rising Star

To change the key names of your JSON you can transform it with JOLT.

The Processor name calls JoltTransformJSON

 

In the property you can "Jolt Specification" you can insert following code, that would be change your key from ServiceGroup to service_group and afterwards you can send the flowfile to the sql processor..

 

[
  {
    "operation": "shift",
    "spec": {
      "ServiceGroup": "service_group",
      "*": "&"
    }
  }
]

 

New Contributor

@Faerballert Thank you very much. This is what I am asking for 😄

But I am having still the problem that the output queue of my ConvertJSONtoSQL, is fillled with the question mark "?".

Am I still missing something?

I thought it would automatically map the json field to the postgresql column and fill the VALUE statement with the values from the json.

 

kaluman_0-1610542427419.png

 

Rising Star

You can use the "PutSQL" Processor to read your content of the sql output and it will be stored in your database.

 

Or maybe instead of ConvertJsonToSQL, you can try it directly with "PutDatabaseRecord" Processor

New Contributor

@FaerballertThanks again. It turned out that I just should ignore the question marks in the SQL statement. Everything works for now.

Take a Tour of the Community
Don't have an account?
Your experience may be limited. Sign in to explore more.