[ 
https://issues.apache.org/jira/browse/CAMEL-9799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15244837#comment-15244837
 ] 

Andreas Gebhardt commented on CAMEL-9799:
-----------------------------------------

Hi Claus,

a short intermediate status on comparison of both Java based JSON schema 
validators. This https://github.com/agebhar1/json-schema-validator-battle is 
the repository. It's a Maven based multi-module Java project. A module for each 
JSON schema validator, because of there dependencies and one for schema and 
example resources.

*Dependencies*

 +- com.github.fge:json-schema-validator:jar:2.2.6:compile
    +- com.google.code.findbugs:jsr305:jar:3.0.0:compile
    +- joda-time:joda-time:jar:2.3:compile
    +- com.googlecode.libphonenumber:libphonenumber:jar:6.2:compile
    +- com.github.fge:json-schema-core:jar:1.2.5:compile
    |  +- com.github.fge:uri-template:jar:0.9:compile
    |  |  +- com.github.fge:msg-simple:jar:1.1:compile
    |  |  |  \- com.github.fge:btf:jar:1.2:compile
    |  |  \- com.google.guava:guava:jar:16.0.1:compile
    |  +- com.github.fge:jackson-coreutils:jar:1.8:compile
    |  |  \- com.fasterxml.jackson.core:jackson-databind:jar:2.2.3:compile
    |  |     +- com.fasterxml.jackson.core:jackson-annotations:jar:2.2.3:compile
    |  |     \- com.fasterxml.jackson.core:jackson-core:jar:2.2.3:compile
    |  \- org.mozilla:rhino:jar:1.7R4:compile
    +- javax.mail:mailapi:jar:1.4.3:compile
    |  \- javax.activation:activation:jar:1.1:compile
    \- net.sf.jopt-simple:jopt-simple:jar:4.6:compile

 +- org.everit.json:org.everit.json.schema:jar:1.2.0:compile
    +- org.json:json:jar:20160212:compile
    +- com.google.guava:guava:jar:19.0:compile
    \- commons-validator:commons-validator:jar:1.5.0:compile
       +- commons-beanutils:commons-beanutils:jar:1.9.2:compile
       +- commons-digester:commons-digester:jar:1.8.1:compile
       +- commons-logging:commons-logging:jar:1.2:compile
       \- commons-collections:commons-collections:jar:3.2.2:compile

The needed dependencies for `fge/json-schema-validator` are much more than that 
of `everit-org/json-schema`. But `fge/json-schema-validator` depends on the 
popular Jackson library which might cause some problems if another version is 
already on the classpath. Both depends on Google's `guava` in which 
`everit-org/json-schema` makes use of current version 19 whereas 
`fge/json-schema-validator` on 16.0.1.

*Failure Reports*

Schema:

{
  "$schema" : "http://json-schema.org/draft-04/schema";,
  "type": "object",
  "required": [
    "a"
  ],
  "properties": {
    "a": {
      "type": "string"
    },
    "b": {
      "type": "number"
    },
    "c": {
      "type": "boolean" 
    }
  }
}

Failing Example:

{
 "a": "foo",
 "b": "1",
 "c": false
}

`everit-org/json-schema`:

#/b: expected type: Number, found: String

`fge/json-schema-validator`:

{
  "level": "error",
  "schema": {
    "loadingURI": "#",
    "pointer": "/properties/b"
  },
  "instance": {
    "pointer": "/b"
  },
  "domain": "validation",
  "keyword": "type",
  "message": "instance type (string) does not match any allowed primitive type 
(allowed: [\"integer\",\"number\"])",
  "found": "string",
  "expected": [
    "integer",
    "number"
  ]
}

So I must revise my statement on failure/error reporting - 
`fge/json-schema-validator` is obviously more precise. 

Hopefully in the next week I would add more sophisticated examples, maybe based 
on tests from `fge/json-schema-validator` and/or `everit-org/json-schema`. JSON 
schema also supports modular style through referencing (sub) schemas. Both 
implementations provide support which need some investigations. 

What did you think?

> JSON/JSON Schema validator
> --------------------------
>
>                 Key: CAMEL-9799
>                 URL: https://issues.apache.org/jira/browse/CAMEL-9799
>             Project: Camel
>          Issue Type: Wish
>            Reporter: Andreas Gebhardt
>
> > Von: Gnanaguru S
> > An: ★ [email protected]
> >
> > Subject: \[DISCUSS\] - Thoughts on Apache Camel 2.18 and towards 3.0
> >
> > \[...\]
> > 7.  JSON validator. XML XSD validation is nice and straight forward, but it
> > will be great if we have something similar for JSON as well. like
> > to:json-validator:classpath/response.json
> > \[...\]



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to