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

0.0.5 • Public • Published

Install

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

Usage

import extractPureJson from 'extract-pure-json'

const str1 = 'hello world { "a": 1, "b": 2 }'
const str2 = 'Hey [{ "a": 1, "b": 2 }]'
const str3 = '{"a": 1} {"b": 2}'
const str4 = '{"a": 1]*&^)}}}}}}'

extractPureJson(str1) // { "a": 1, "b": 2 }
extractPureJson(str2) // false
extractPureJson(str3) // {"a": 1}
// sometimes the string is so long
// maybe it has not json style ,you can use retry option
extractPureJson(str4, {retry: 10}) // false

Readme

Keywords

Package Sidebar

Install

npm i extract-pure-json

Weekly Downloads

0

Version

0.0.5

License

ISC

Unpacked Size

3.5 kB

Total Files

4

Last publish

Collaborators

  • blackberry007