Skip to content

Safely serialize JavaScript expressions to a superset of JSON, which includes Dates, BigInts, and more.

License

Notifications You must be signed in to change notification settings

blitz-js/superjson

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

superjson

Safely work with dates, bigints, and more with this superset of JSON.

npm Language grade: JavaScript CI

Backstory

...

Key features

  • 🍱 Reliable serialization and deserialization
  • 🔐 Type safety with autocompletion
  • 🐾 Negligible runtime footprint
  • 💫 Framework agnostic

Example

const input = {
  normal: 'string',
  timestamp: new Date(),
};

const { json, meta } = serialize(input);

/*
json = {
  normal: 'string',
  timestamp: "2020-06-20T04:56:50.293Z",
}

meta = {
  timestamp: 'Date',
}
*/