Question: In my Java Application i'm getting Request parameter like Array

```
<script type="text/javascript">
   var names = new Array();
    $.ajax({
        url : "Result",
        type : 'POST',
        data : {
            "names" : JSON.stringify(names),
            "globalClassId" : globalClassId
        }});
</script>

```

Now i'm getting this request parameter in java and retrieve the values correctly..

```
//Get the each added user using names[]
    for (String id : names) {
        -----
                    -----
    }

```

But in java side i'm getting values `names=[["1000"]]` and in for loop i'm getting `id=["value1"]`

if we pass this value to database for example select query,But it is giving null value.. even we pass correct value but we are getting null value.

How to remove this extra brackets in my String `["1000"]` this is original value but i want only `1000`.

Please help me is their any wrong declaration in Array.

Answer: 
use [**org.json**](http://www.json.org/java/) 

```
 JSONObject obj = new JSONObject(request.getParameter("names"));

List<String> list = new ArrayList<String>();
JSONArray array = obj.getJSONArray("interests");
for(int i = 0 ; i < array.length() ; i++){

}

```
First thing i want to tell you that generate your JSON like a list or Map Structure so that you can get Structure using any JSON or GSON Api.

It will make simple for you to retrieve them & no other Constraints needed in future to retrieve them.