Skip to content

A small utility that parses JSON and converts date fields to Date type.

License

Notifications You must be signed in to change notification settings

giacomorebonato/parse-json-with-dates

Repository files navigation

parse-json-with-dates

Statements Branches Functions Lines
Statements Branches Functions Lines

A small utility that parses JSON and converts date fields to Date type.

Documentation

Example

import { parseJsonWithDates } from 'parse-json-with-dates'

const parsed = parseJsonWithDates(
  JSON.stringify({ 'date-field': new Date() }),
  ['date-field']
)

parsed.a.toISOString() // it's a date!
import { parseJsonWithDates } from 'parse-json-with-dates'

type MyDate = {
  a: Date
}

const parsed = parseJsonWithDates<MyDate>(
  JSON.stringify({ 'date-field': new Date() }),
  ['date-field']
)

parsed.a.toISOString() // it's a date!

About

A small utility that parses JSON and converts date fields to Date type.

Resources

License

Stars

Watchers

Forks

Packages

No packages published