且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Apache Nifi 1.6:崩溃 Groovy 脚本

更新时间:2023-12-05 14:34:52

这段代码的问题:

def json = new groovy.json.JsonBuilder( jsonObject )      // <--- at this point `json` is a JsonBuilder object
outputStream.write(json.getBytes(StandardCharsets.UTF_8)) // JsonBuilder does not have .getBytes(StandardCharsets.UTF_8) method

添加 .toString().toPrettyString() 应该可以解决问题

adding .toString() or .toPrettyString() should fix the problem

def json = new groovy.json.JsonBuilder( jsonObject ).toPrettyString()
outputStream.write(json.getBytes(StandardCharsets.UTF_8))