dotnet-json-date
parse and stringify .net JSON dates
Last updated 4 years ago by refractalize .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install dotnet-json-date 
SYNC missed versions from official npm registry.

.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
};

Current Tags

  • 2.0.1                                ...           latest (4 years ago)

2 Versions

  • 2.0.1                                ...           4 years ago
  • 2.0.0                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (2)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |