Validating JSON Files as Lottie Animations
kkatsi opened this issue · comments
Kostas Katsinaris commented
Hey!
I'm trying to figure out a straightforward way to confirm/validate if a JSON file is actually a Lottie animation using js. One idea I had is to check for certain key properties like "v", "w", "h", "fr", and "layers", but it doesn't sound safe enough.
Would love to hear any suggestions or thoughts on this. Thanks!
Naail Abdul Rahman commented
For a very fast validation the approach you suggested should work fine. We use the same at LottieFiles for the first layer of checks.
For more in-depth validation, there are a few options
- We have a json schema on our lottie-docs page, which you can use to run a schema based validation
- We have an AST parser stack called reLottie which can be used and extended with plugins for this task