September 2010
1 post
3 tags
Ruby JSON Serialization sucks for Time objects
This is something to be very careful of if you need to transfer data between two ruby-based systems using JSON. If you serialize a Time object it will serialize as a string, this means on deserialization it stays as a string
Let me demonstrate:
test_data = {“time” => Time.now}
json = test_data.to_json
# the timestamp looks like this in json “Tue Sep 28 14:37:37...