java-json-tools / json-schema-validator

A JSON Schema validation implementation in pure Java, which aims for correctness and performance, in that order
http://json-schema-validator.herokuapp.com/
Other
1.63k stars 399 forks source link

When JSONObject contains JSONArray, JSONArray's object can not be validated #399

Open Endwas opened 2 years ago

Endwas commented 2 years ago

like this

        JSONObject jsonObject = new JSONObject();

         jsonObject.put("v1", "v1");
        JSONArray array = new JSONArray();

        //wrong 
        JSONObject object2 = new JSONObject();
        object2.put("o", "o2");
        array.add(object2);

        //right
        JSONObject object1 = new JSONObject();
        object1.put("o", 123);
        array.add(object1);
        jsonObject.put("array", array);

isSuccess = false.

        JSONObject jsonObject = new JSONObject();
         jsonObject.put("v1", "v1");
        JSONArray array = new JSONArray();

        //right
        JSONObject object1 = new JSONObject();
        object1.put("o", 123);
        array.add(object1);

        //wrong 
        JSONObject object2 = new JSONObject();
        object2.put("o", "o2");
        array.add(object2);
         jsonObject.put("array", array);

isSuccess = right