check if multiple keys are present in a JSON String – Java

I have a complicated JSON String (Array/Object) and I have to check whether it contains some keys.Its basically a validation for the JSON String I got.

eg

inputJson:{
    a:[
        {
            key1:val1,
            key2:val2
        },{
            key1:val1,
            key2:val2
        },
    ],
    b:
    c:{
        key3:val3,
        key4:val4
    }
}

and I have to verify if the JSON contains a, c , c.key4 ,a[*].key1 .

I have seen many other discussions here , but either its not supporting array inside object or its using heavy libraries for JSON Validation. What I am looking for is a simple library or method which just checks if the keys are present in a JSON String.

Please give me pointers on how to do this.

Thank you


Source: json

Leave a Reply