Forum Discussion
I’ve tried the same as I showed you in response above, only thing that I’ve changed was that I was using fields that you provided in the post and I couldn’t work them out anyhow.
I’ve also tried with apache velocity but nothing.
Problem are those “:” you have in the name. I don’t know why but you can not map fields in JSON Generator with square brackets.
Solution could be as you said to map the first in mapper and pass it to JSON Generator with null-safe-access, or with expression to remove those “:” from the name of the field.
@Charles Please note the following documentation at the top of the default template in the JSON Generator:
Enter your JSON-encoded data in this space. Note that this text is
treated as an Apache Velocity template, so you can substitute values
from input documents or the pipeline parameters. See the following
URL for more information about Velocity:
https://velocity.apache.org/engine/devel/user-guide.html
This means you can use Velocity syntax, not SnapLogic EL syntax, in your templates, like this:
[
{
"result" :
#if($msg)
${msg}
#else
${fallback}
#end
}
]
Here’s a pipeline to demonstrate this:
Velocity Null Check_2021_12_07.slp (4.8 KB)
You can do the same on a single line like this:
"result" : #if($msg) $msg #else $fallback #end
- ptaylor3 years agoEmployee
Ok. And you’ve set up the Mapper to map a string from the input document to the special field
content
, like this?
Why do you need the Transcoder? The ASCII character set is extremely limited (only 128 characters) so if there are characters in the input that can’t be transcoded to ASCII that would be why you’re seeing that error. (The error message is confusing.)