dotnet-json-date

2.0.1 • Public • Published

.Net JSON Date npm version npm

Parse and stringify .Net JSON dates.

npm install dotnet-json-date

Usage

var dotnetJsonDate = require('dotnet-json-date');

Parse

var date = dotnetJsonDate.parse('/Date(1466121600000)/')
 
date == new Date(1466121600000);

Stringify

var string = dotnetJsonDate.stringify(new Date(1466121600000))
 
string == '/Date(1466121600000)/';

JSON.stringify replacer

Stringify all dates to .Net JSON dates when stringifying JSON

var object = {
  name: 'bob',
  birthday: new Date(1466121600000),
  numberOfEyes: 3
};
 
var json = JSON.stringify(object, dotnetJsonDate.replacer);
 
json == '{"name":"bob","birthday":"/Date(1466121600000)/","numberOfEyes":3}';

JSON.parse reviver

Parse all .Net JSON dates when parsing JSON

var json = '{"name":"bob","birthday":"/Date(1466121600000)/","numberOfEyes":3}';
 
var object = JSON.parse(json, dotnetJsonDate.reviver);
 
object == {
  name: 'bob',
  birthday: new Date(1466121600000),
  numberOfEyes: 3
};

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 2.0.1
    96
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 2.0.1
    96
  • 2.0.0
    0

Package Sidebar

Install

npm i dotnet-json-date

Weekly Downloads

72

Version

2.0.1

License

ISC

Last publish

Collaborators

  • refractalize