extract-first-json
TypeScript icon, indicating that this package has built-in type declarations

2.0.2 • Public • Published

extract-first-json

NPM TypeScript

Extract the first JSON object or array from a string.

If I should maintain this repo, please ⭐️ GitHub stars

DM me on Twitter if you have questions or suggestions. Twitter


Installation

yarn add extract-first-json
npm install extract-first-json
pnpm add extract-first-json

Usage

import { extractJSON, extractJSONObject, extractJSONArray } from "extract-first-json";

const string = `Example: { "ok": true }`;

const arrayString = `Example: [{ "ok": true }]`;

extractJSON(string); // { ok: true }

extractJSONObject(string); // { ok: true }

extractJSONArray(arrayString); // [{ "ok": true }]

Dependenciesdependencies


Dev Dependencies

  • autorepo: Autorepo abstracts away your dev dependencies, providing a single command to run all of your scripts.

License license

MIT

Dependencies (2)

Dev Dependencies (1)

Package Sidebar

Install

npm i extract-first-json

Weekly Downloads

5,284

Version

2.0.2

License

MIT

Unpacked Size

6.11 kB

Total Files

8

Last publish

Collaborators

  • bconnorwhite