Skip to content

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

@Endwas

Description

@Endwas

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions