fixed the column<-->row ordering in matrix to json conversion