Apache NiFi Record Path ReferencePDF version

escapeJson

JSON Stringifies a Record, Array or simple field (e.g. String), using the UTF-8 character set. For example, given a schema such as:

{
  "type": "record",
  "name": "events",
  "fields": [{
    "name": "person",
    "type": "record",
    "fields": [
      { "name": "name", "type": "string" },
      { "name": "age", "type": "int" }
    ]
  }]
}

and a record such as:

{
  "person": {
    "name" : "John",
    "age" : 30
  }
}

The following record path expression would convert the record into an escaped JSON String:

RecordPath

Return value

escapeJson(/person)

"{\"person\":{\"name\":\"John\",\"age\":30}}"

escapeJson(/person/firstName)

"\"John\""

escapeJson(/person/age)

"30"