Echo JS example

Returns the JS code provided in URL

HTML

<pre></pre>

JavaScript

// This code will be loaded as a separate file
var code = '{\
    "ID":10079,\
    "DateTime":new Date(1288384200000),\
    "TimeZoneID":"W. Europe Standard Time",\
    "groupID":284,\
    "groupOrderID":10\
}';

// Load and run a JS file
$.get("/echo/js/?js=" + code, function (data) {
    var fullResultJSON = data.replace(/new Date\((\d+)\)/g, '$1');
    var messageAsJSObj = JSON.parse(fullResultJSON, function (key, value) {
        if (key == "DateTime")
            return new Date(value);
    
        return value;
    });
    
    $("pre").text("DateTime field value is: "+messageAsJSObj.DateTime);
});

var almostJSON = '{
    "ID": 10079
}';