4

I am trying to validate my JSON using ( https://github.com/fge/json-schema-validator) schema validator.

  1. Do you recommend using jackson schema generation to generate JSON schemas or is there a better way ?

  2. I have an object called (Location) which has list of objects (BaseObject). I created a schema for location like this with a $ref to BaseObject. But validation fails with the error message - ["": domain: validation; keyword: properties; message: required property(ies) not found; missing: ["id","refName"]; required: ["id","refName"]]

Is there a mistake in the way I used the refs ?

Location.json - schema

{
   "type":"object",
   "properties":{
      "locationType":{
         "type":"string"
      },
      "mapsRefs":{
          "$ref": "file://localhost/c:/baseobject.json" 
         }
      }
   }
}

baseobject.json - schema

{
   "type":"object",
   "properties":{
      "refName":{
         "type":"string",
          "required":true
      },
      "id":{
         "type":"integer",
          "required":true
      },
      "refs":{
         "type":"array",
          "required":false,
         "items":{
            "type":"string"
         }
      }
   }

}
1
  • 1
    in Location.json is one too much closing bracket Commented Jun 24, 2013 at 15:02

1 Answer 1

1
+50

To answer your first question, Jackson in my experience is the most easy to use and documented API to handle JSON on java.

For the second question you define the "id" and "refName" as required, you are either validating with the wrong schema, or not passing the required properties.

This does look a lot like this closed issue on github: https://github.com/fge/json-schema-validator/issues/22

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.