Passed the grid as json string

Since passing the grid as a large 2D array caused some problems with
php, I used a json string instead.