get-json-val
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published

get-json-val

Read this in other languages: English

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

安装

npm install get-json-val

或者

yarn install get-json-val

用法

参数

参数 说明 类型 默认值
val JSON 字符串 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 完成基本功能

/get-json-val/

    Package Sidebar

    Install

    npm i get-json-val

    Weekly Downloads

    1

    Version

    0.0.2

    License

    MIT

    Unpacked Size

    8.76 kB

    Total Files

    13

    Last publish

    Collaborators

    • wsa123456