This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

@architecturex/utils.isjson
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

@architecturex/utils.isjson

isJSON(str: string): boolean

The isJSON function checks if a provided string is a valid JSON string. This can be particularly useful in scenarios where you receive data as strings and need to determine if they can be safely parsed as JSON.

Installation

npm install @architecturex/utils.isjson

Usage

import isJSON from '@architecturex/utils.isjson'

const data = '{"name": "John", "age": 30}'

if (isJSON(data)) {
  console.log('Valid JSON string!')
} else {
  console.log('Not a JSON string')
}

Common Use Cases

  • Validating incoming data in API endpoints
  • Safe JSON parsing in applications to prevent runtime errors
  • Checking user input in forms where JSON strings might be provided

Contribution

Feel free to suggest improvements, report issues, or contribute to enhancing this utility. Your feedback and contributions are welcome!

Package Sidebar

Install

npm i @architecturex/utils.isjson

Weekly Downloads

1

Version

1.0.2

License

MIT

Unpacked Size

3.27 kB

Total Files

5

Last publish

Collaborators

  • architecturex