I have the following JSON which I am parsing using a generic function and expecting a return value.
{
    "items":
    {
        "item":
        {
            "Beverages":
                [
                    {
                        "id": "0004",
                        "name": "Thums Up",
                        "image":{"url": "images/0001.jpg","width": 200,"height": 200},
                        "Can":[ "250ml", "300ml","330ml", {"image":"images/0001.jpg" }],
                        "Bottle":[ "350ml",  "600ml", {"image":"images/0001.jpg" } ],
                        "Fountain":["small", "large", {"image":"images/0001.jpg" }]
                    },
                    {
                        "id": "0005",
                        "name": "Pepsi",
                        "image":{"url": "images/0001.jpg","width": 200,"height": 200},
                        "Can":[ "250ml", "300ml","330ml", {"image":"images/0001.jpg" }],
                        "Bottle":[ "350ml",  "600ml", {"image":"images/0001.jpg" } ],
                        "Fountain":["small", "large", {"image":"images/0001.jpg" }]
                    }
                ],
            "Snacks":
                [
                    {
                        "id": "0010",
                        "name": "Puffs",
                        "image":{"url": "images/0001.jpg","width": 200,"height": 200},
                        "Veg":["Veg puff", {"image":"images/0001.jpg" }],
                        "Egg":["Egg puff", {"image":"images/0001.jpg" }],
                        "Chicken":["Chicken puff", {"image":"images/0001.jpg" }]
                    },
                    {
                        "id": "0011",
                        "name": "Samosa",
                        "image":{"url": "images/0001.jpg","width": 200,"height": 200},
                        "Aloo Samosa":["small", "big", {"image":"images/0001.jpg" }],
                        "Corn Samosa":["small", "big", {"image":"images/0001.jpg" }]
                    }
                ]
        }
    }
}
In my program, I am passing the value and expecting an array from that.
This is my complete program. I am using jQuery for this.
I am doing it this way:
$(document).ready(function (jsondata) {
    var value = 'Beverages';
    var retdata[] = returnValues(value);
    for (int i = 0; i < retdata.length; i++) {
        alert(retdata[i]);
    }
});
function returnValues(value) {
    var data = [];
    $.each(jsondata.items.item, function (i, v) {
        if (i == value) {
            data.push[i];
        }
    });
    return data;
}
I am a Java developer with very minimal JS knowledge so if this way is completely wrong also please let me know, so that I can change that accordingly.
sorry if this is incomlete question ,and made you confusing .
my question is I mean if you see the json above ,and if i pass the value Pepsi value directly , can i get image , Can , Bottle and Fountain values ?? and similarly if i pass the value Beverages , i should get all the child elemnts of Beverages
 
    