Search code examples
javascriptjsonobjectserializationstringify

Stringify timestamp object


How can i JSON.stringify the following data-structure?

var Records = {
    1357775376232: {
        pageX: 0,
        pageY: 0,
        scrollLeft: 0,
        scrollTop: 0,
        target: #document,
        type: null,
        value: undefined
    },
    1357775376243: {
        pageX: 69,
        pageY: 10,
        scrollLeft: 0,
        scrollTop: 0,
        target: <a>,
        type: "click",
        value: ""
    }
    // ...etc...
};

Solution

  • Instead of using a plain object, use the XPath for the elements.