01-02-2019 02:03 AM
Hi
i’m trying to validate simple json data against particular json schema using python script.
i’m trying to use ‘cerberus’ library of python but script snap is failing with error.
How we can import external library and use it in script snap?any other native library that can be use so that we can avoid loading of external library?
JSON Formatter snap can be used to validate json by specifying Schema file ?
validate_2019_01_02.slp (10.4 KB)
test.schema.txt (366 Bytes)
01-02-2019 07:37 AM
Try checking out this post and see if that can help get you started. How to use 3rd party python libraries in python Script - #6 by Bhavin. I believe the script snap uses Jython to execute and so you may only be able to import Java libraries for use in the script.
01-03-2019 01:36 AM
Hi ,
as suggested in post ,i have added “json-schema-validator-2.1.7.jar” .
error maessage:-
validate_2019_01_03.slp (10.5 KB)
01-04-2019 07:17 AM
I don’t think the approach I suggested will work unless you can add the dependency to the plex node you are running the script on. Are you running this on a groundplex or a cloudplex? I assume if you’re a trial user, then you probably have a cloudplex in which case this isn’t going to work.
Let me ask around and see if anyone else can think of a solution that works for you.
01-09-2019 01:24 PM
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.