Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

CharacterTypeEscape string

backspace

Represented As "\b"
Escaped "\\\\b"
form feedRepresented As "\f"
Escaped"\\\\f"
tabRepresented As"\t"
Escaped "\\\\t"
carraige returnRepresented As"\r"
Escaped "\\\\r"
newlineRepresented As"\n"
Escaped "\\\\n"
backslashRepresented As

"\\\\"

Escaped "\\\\\\\\"
double quoteRepresented As'"'
Escaped '\\\\"'

Macro: Escaping Invalid Characters

If you are outputting stream data into JSON format, the data can include special characters that JSON will not accept. The following macro escapes these invalid characters. 

...


Code Block
do(
    $value = $args[1],
    $value = replaceAll( $value , "\b","\\\\b"),
    $value = replaceAll( $value , "\f","\\\\f"),
    $value = replaceAll( $value , "\t","\\\\t"),
    $value = replaceAll( $value , "\r","\\\\r"),
    $value = replaceAll( $value , "\n","\\\\n"),
    $value = replaceAll( $value , "\\\\","\\\\\\\\"),
    $value = replaceAll( $value , '"','\\\\"')
)


Validating Data Imported Into PhixFlow

JSON data (like any imported data format) can include characters that cannot be written to a database that is using the UTF-8 character set. For example, 4-bit Emojis are not supported by UTF-8.

The following regular expression lists the characters expected in a JSON file and removes invalid characters from it.

Code Block
replaceAll(JSON Code,"[^\\p{Space}0-9A-Za-z!:\\\"%&\\[*()\\],-/_\\\\{}\\.]","")

The backslash character escapes special characters such as [] , . and \ 

Tip

Check which database PhixFlow is running on to see how it handles 4-bit characters. An oracle database with the recommended configuration can store the full range of Uni-code characters whilst MySQL/MariaDB UFT-8mb3 databases cannot and invalid characters will need to be removed before writing to the database. See Database for recommended database configurations. 

See also: Regular Expressions


...