fixed error where comma would be appended to last element of an array or object