Skip to content

sidmishraw/jsonpath-syntax-validator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JSON Path expression syntax validation

This project uses the JSON Path expression parsing logic mentioned in Stefan Goessner's article. I make use of parts of the code from original JSON path implementation in JS found here.

Usage

class Example {
    public static void main(String[] args) {
        JsonPathValidator validator = new BasicJsonPathValidator();
        Assert.assertTrue(validator.validate("$.as[?(@.name == 'samba')]"));
        Assert.assertFalse(validator.validate("a['??kangaroo   \"A\"'][??(@.name == 'a')].value"));        
    } 
}

JsonPathValidator is an interface that has a basic implementation BasicJsonPathValidator. If required other sophisticated validators can be added to this library.

Note: This library doesn't really evaluate the path against a JSON object, this is strictly pre-evaluation phase syntax check.

Dependencies

  • Project Lombok
  • Maven
  • Slf4j
  • Logback

References

[1] https://goessner.net/articles/JsonPath/

[2] https://code.google.com/archive/p/jsonpath/

About

Validates the syntax of a JSON path expression.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages