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

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 2.0.2
    8
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 2.0.2
    8
  • 2.0.1
    2
  • 2.0.0
    2
  • 1.0.1
    7,187
  • 1.0.0
    1

Package Sidebar

Install

npm i extract-first-json

Weekly Downloads

4,463

Version

2.0.2

License

MIT

Unpacked Size

6.11 kB

Total Files

8

Last publish

Collaborators

  • bconnorwhite