Forum Discussion
So I talked with a couple people and here are some options. You can use a snap called the DataValidator that allows some similar options to what JsonSchema provides. Here is an example that uses constraints similar to what you were looking to do.
data-validator-example_2019_01_09.slp (5.8 KB)
The other option is to use some of the XML snaps as those have validation built into them. I guess the data validation is more common with the XML use cases from what we’ve seen. So you could do something like this, which would do the validation in the XML snaps.
thank you @tlikarish for suggesting alternative options.
- mohamadelmardin7 years agoNew Contributor III
First you have to use the out-of-box XML parser snap and configuring it should be easy as described in SnapLogic documentation. Then the hard part begins after the incoming XML input parsed into JSON is to navigate through the nested structure and map any array or non-existing elements. The best way to do that is to use a series of Mapper snaps and in each mapper you have to use expression language statements which is a subset of JavaScript. To read more about expression language please check the following link:
https://docs-snaplogic.atlassian.net/wiki/spaces/SD/pages/1438042/Expression+Language+OverviewFor example to cast an parsed XML element in JSON into an array type you would use the following expression: [].concat[ element ]
Please refer also to the beginning of this thread for other examples.
Related Content
- 6 months ago
- 11 months ago
- 2 years ago
- 4 years ago