Forum Discussion

Ajay_Chawda's avatar
Ajay_Chawda
Contributor
7 years ago

How to implement jsonschema validation using Python script

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)

5 Replies

  • 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.

  • 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.