Skip to content
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 

parse-json-object

NPM TypeScript Coverage Status GitHub Stars Twitter Follow

Parse a typed JSON object.

  • Returns undefined if unable to parse
  • Returns typed JSON object if successful

Installation

yarn add parse-json-object
npm install parse-json-object

API

Types

import parse, {
  parseJSONValue,
  parseJSONObject,
  parseJSONArray,
  parseString,
  JSONValue,
  JSONObject,
  JSONValue,
  JSONArray
} from "parse-json-object";

function parse<T extends JSONValue>(value: string | undefined, isType: (value: T) => boolean): T | undefined;

function parseJSONValue<T extends JSONValue>(value?: string): T | undefined;

function parseJSONObject<T extends JSONObject>(value?: string): T | undefined;

function parseJSONArray<T extends JSONArray>(value?: string): T | undefined;

function parseString<T extends string>(value?: string): T | undefined;

type JSONValue = string | number | boolean | null | JSONObject | JSONArray;

type JSONObject = {
  [key in string]?: JSONValue
};

interface JSONArray extends Array<JSONValue> {};

Dependenciesdependencies


Dev DependenciesDavid


License license

MIT


Related Packages:

About

Parse a typed JSON object

Topics

Resources

Packages

No packages published