Demos
Documentation
API
More Samples
Download Wijmo

Loading JSON Dates

JSON is a great format for serializing data, but unfortunately it does not support dates.

The Problem

If you serialize an object that contains date fields using JSON.stringify, the dates will be converted to strings. If you then parse the same object using JSON.parse, the date fields will remain strings.

The Solution

The solution for this problem is to use a 'reviver' function in the call to JSON.parse that will inspect the strings and convert those that look like dates into date objects.