$ gnpm install extract-first-json
Extract the first JSON object or array from a string.
If I should maintain this repo, please ⭐️
DM me on Twitter if you have questions or suggestions.
yarn add extract-first-json
npm install extract-first-json
pnpm add extract-first-json
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 }]
Copyright 2013 - present © cnpmjs.org | Home |