Include array index when serializing nested arrays

Needed for jquery & PHP compatibility