New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

get-json-val

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

get-json-val

At the same time, it is a function to judge whether it is a JSON string and the result of parsing the JSON string.

latest
npmnpm
Version
0.0.2
Version published
Maintainers
1
Created
Source

get-json-val

Read this in other languages: English

同时判断是否是 JSON 字符串以及解析 JSON 字符串的结果的函数。

安装

npm install get-json-val

或者

yarn install get-json-val

用法

参数

参数说明类型默认值
valJSON 字符串string-
import { getJSONVal } from 'get-json-val'

getJSONVal(null as any)
// [new Error('value must be a string'), null]

getJSONVal('')
// [new Error('value must be a string'), null]

getJSONVal('a: 1')
// [new SyntaxError('Unexpected token a in JSON at position 0'), null]

getJSONVal('{"a":1}')
// [null, { a: 1 }]

升级日志

  • 0.0.2 完成基本功能

Keywords

JSON

FAQs

Package last updated on 01 Feb 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts