extract-first-json
Extract the first JSON object or array from a string
Last updated 2 years ago by bconnorwhite .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ gnpm install extract-first-json 
SYNC missed versions from official npm registry.

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

Current Tags

  • 2.0.2                                ...           latest (2 years ago)

5 Versions

  • 2.0.2                                ...           2 years ago
  • 2.0.1                                ...           2 years ago
  • 2.0.0                                ...           2 years ago
  • 1.0.1                                ...           4 years ago
  • 1.0.0                                ...           4 years ago
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (2)
Dev Dependencies (1)
Dependents (1)

Copyright 2013 - present © cnpmjs.org | Home |