I need the count the number of specific array (coreid) present in response JSON Since, response I'm getting is pretty huge, I am using following JSON as example:
 {
    "errors": [],
    "data": {
        "products": {
            "number": 0,
            "size": 2,
            "total": 2,
            "results": [{
                    "assetId": "29-test-ENG",
                    "fields": {
                        "majoracademic": [
                            "test stream 1"
                        ],
                        "learningobjective": [
                            "test objective 1"
                        ],
                        "hasproductprice": [
                            "0"
                        ],
                        "comingsoon": [
                            "0"
                        ],
                        "coreid": [
                            "12"
                        ],
                        "previewCount": [
                            "0"
                        ],
                        "type": [
                            "page(s)"
                        ]
                    }
                },
                {
                    "assetId": "01-test-MTH",
                    "fields": {
                        "majoracademic": [
                            "test stream 2"
                        ],
                        "learningobjective": [
                            "test objective 2"
                        ],
                        "hasproductprice": [
                            "0"
                        ],
                        "comingsoon": [
                            "0"
                        ],
                        "coreid": [
                            "12"
                        ],
                        "previewCount": [
                            "0"
                        ],
                        "type": [
                            "page(s)"
                        ]
                    }
                }
            ]
        }
    }
 }
So Basically I need to count array "coreid" occurrence in this JSON, which is actually 2 but my code is returning 3 times, I'm using the following code:
protected String  getTokenValueUnderHierarchyString( String Json) throws ClientProtocolException, IOException {
    List<String> list = Arrays.asList(Json.split("coreid"));
    System.out.println("list.size()::"+list.size());
}
I printed the values of array, turns out it takes complete JSON object as 1st element. So even If I type "coreid1, array count it will return is 1. and the value would be complete JSON.
I hope my question is making any sense.
 
     
    