ToJSON Method (Date) (JavaScript)
Syntax: Objectname.tojson ()
ObjectName
Necessary. The object that needs to be JSON serialized.
The ToJSON method is a built-in member of a Date JavaScript object. It returns the ISO format date string (denoted by the suffix Z) of the UTC time zone.
The following example uses the ToJSON method to serialize uppercase string member values. The ToJSON method is called when Json.stringify is called.
varContact =NewObject (); Contact.firstname = "Jesper"; Contact.surname = "Aaberg"; Contact.phone= ["555-0100", "555-0120"]; Contact.tojson=function(key) {varReplacement =NewObject (); for(varValinch This){ if(typeof( This[Val]) = = = ' String ') Replacement[val]= This[Val].touppercase (); ElseReplacement[val]= This[Val]}returnreplacement;}; varJsontext =json.stringify (Contact); /*The value of Jsontext is: ' {"FirstName": "JESPER", "surname": "Aaberg", "Phone": ["555-0100", "555-0120"]} '*/
ToJSON Method (Date) (JavaScript)