Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
import java.nio.charset.*
import org.json.JSONObject;
import org.json.XML;
def flowFile = session.get()
if (!flowFile) return
flowFile = session.write(flowFile,
{ inputStream, outputStream ->
def text = IOUtils.toString(inputStream, StandardCharsets.UTF_8)
def xmlJSONObj = XML.toJSONObject(text);
def json = xmlJSONObj.toString();
} as StreamCallback)
flowFile = session.putAttribute(flowFile, "mime.type", "application/json")
session.transfer(flowFile, ExecuteScript.REL_SUCCESS)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment