Using object of class JSON to encode data.