Q:

How to get values in Json Array and use each of them separately

I have a JSON and I Want to separate each field of that in array part and then I want to use of each field separately and put them in separate array. 
for example I have two part in my array and I want to divide the first part too room 1 and second part in room 2 . 
I have to send Json to my second page with format room1 and room 2. and I do not know how can I do this
my json is like this right now :
"rooms": [
    {
      "adultcount": "1",
      "childcount": "1,1"
    },
    {
      "adultcount": "1",
      "childcountandage": "0 "
    }
]

but I want to change it like this : 
"rooms": [
    {
        "rooms1": {
            "adultcount": "1",
            "childcount": "1,1"
        }
    },
    {
        "rooms2": {
            "adultcount": "2",
            "childcount": "10,1"
        }
    }
]

then I need to use them.
how can I do this with jquery ?
there is no need to change the json code I just wrote the sample the new json to define better.
here is my code :
$( document ).ready(function() {
var research={"rooms":[{ "adultcount":"1","childcount":"1,1" },{ "adultcount":"1","childcountandage":"0 " }] }
var adultcount = research.rooms[0].adultcount;
var childcount = research.rooms[0].childcount;

});

A:

Since you have an array that you want to make into an object and the property name seems to be the index inside the array, you can use a basic array.reduce:

var rooms = [
    { "adultcount":"1", "childcount":"1,1" },
    { "adultcount":"2", "childcount":"10,1" }
];

var roomsMap = rooms.reduce( function( map, room, index ) {
    map[ 'room' + ( index + 1 ) ] = room;
    return map;
}, {} );

var otherRoomsMap = rooms.map( function( room, index ) {
    var wrapper = {};
    wrapper[ 'room' + ( index + 1 ) ] = room;
    return wrapper;
} );

console.log( roomsMap );

console.log( otherRoomsMap );

edit:
I have added the other example of keeping the array and just wrapping the objects isnide another object, but I have no idea what advantage that would give over the original array.

