- Subscribe to RSS Feed
- Mark Question as New
- Mark Question as Read
- Float this Question for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
Nifi EvaluateJsonPath remove escape
- Labels:
-
Apache NiFi
Created 04-02-2018 12:23 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
First of all, a data sample :
{ "type" : "Feature", "properties" : { "commune" : "VENISSIEUX", "voie" : "Rue Eugène Hénaff", "numerodansvoie" : "10", "gestionnaire" : "NET Sud-Est", "observation" : "Entrée Subdivision NET SUD-EST face \"magasin\"", "identifiant" : "C61544", "gid" : "15" } }
We can see about the observation field value, there are double quotes already escaped from the source. Perfect for the next operations, but...
When I use EvaluateJsonPath to set an flowfile attribute from this value, like this :
observation ----> $.properties.observation
Value is not :
Entrée Subdivision NET SUD-EST face \"magasin\"
But :
Entrée Subdivision NET SUD-EST face "magasin"
Double quotes are removed. This is a problem because I push this data in MariaDB. So classic "syntax error".
There are lot of solutions like ReplaceText, "?" with sql.args (but sometimes values are empty, an exception occurs). But there is a solution with EvaluateJsonPath directly ?
Thanks !
Created 04-02-2018 12:34 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm not sure if there is a function in JSONPath to retain the escaped quotes or not, but you could use UpdateAttribute (between EvaluateJsonPath and ReplaceText) along with the escapeJson function to "re-introduce" the quotes, by setting the "observation" attribute to the following value:
${observation:escapeJson()}
