1.0.4 • Published 11 months ago

extract-json-from-text v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

Extract Json From Text

Extract a JSON oboject or array from any piece of text

Usage

Install

npm i extract-json-from-text

Import

const { jsonFromText } = require("extract-json-from-text");
import { jsonFromText } from "extract-json-from-text";

Object Extraction

By default, it looks for an object in the string text

const str = `Lorem ipsum dolor sit amet, { "hello": "World" } consectetur adipiscing elit.`;
const jsonResults = jsonFromText(str);
console.log(jsonResults); // Object { "hello": "World" }

Array

If you have to extract an array from the text

const str = `Lorem ipsum dolor sit amet, [ "hello", "World" ] consectetur adipiscing elit.`;
const jsonResults = jsonFromText(str, "array");
console.log(jsonResults); // Array [ "hello", "World" ]
1.0.4

11 months ago

1.0.3

11 months ago

1.0.2

11 months ago

1.0.1

11 months ago

1.0.0

11 months ago