NiFi ConvertJsonToSQL处理器JSON对象存入数据库列值为空的原因及存储方法咨询
InboundData Value in ConvertJsonToSQL Let's break down why your InboundData parameter is ending up as an empty string, and how to fix it to store the JSON object as text in your database.
Possible Root Cause
The documentation states that JSON objects mapped to fields should be interpreted as text, but it seems the tool isn't properly serializing the nested InboundData object into a string. This might happen due to:
- A bug in the ConvertJsonToSQL tool where nested JSON objects aren't being stringified correctly, falling back to an empty string instead.
- Missing configuration or a required setting that enables serialization of nested objects to text.
- Implicit type checking that's rejecting the JSON object instead of converting it.
Solutions to Store the JSON Object as Text
1. Manually Stringify the Nested JSON Object
Instead of passing the InboundData as a nested JSON object, convert it to an escaped JSON string first. Modify your input JSON like this:
{ "Code" : "27037834", "ProductID" : "2", "CalculationStatusId" : "1", "SystemCode" : "aCRM", "InboundData" : "{ \"dateEndM\" : \"2021-12-14 00:00:00.0\", \"dateEndY\" : \"2022-01-11 00:00:00.0\" }" }
This explicitly provides the JSON as a string, which the tool should correctly map to the InboundData parameter without converting it to an empty value.
2. Check for Tool Configuration Settings
Look for any settings in ConvertJsonToSQL related to handling nested JSON objects. Some tools require you to explicitly enable serialization of objects to text fields, or specify the target database field type (like TEXT or VARCHAR) to trigger the correct conversion.
3. Update to the Latest Tool Version
If this is a known bug, the maintainers might have fixed it in a newer release. Check the tool's release notes or issue tracker for reports of empty values with nested JSON objects, and upgrade if a fix is available.
内容的提问来源于stack exchange,提问作者Alan M

