# @adtkcn/jsonfunc

> 支持解析包含function的json

Latest version **1.0.3** (published 2023-02-24) · ISC license · 0 weekly downloads

## Install

```sh
npm install @adtkcn/jsonfunc
pnpm add @adtkcn/jsonfunc
yarn add @adtkcn/jsonfunc
bun add @adtkcn/jsonfunc
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2023-02-24 |
| First published | 2023-02-24 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 3.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | heng,yue |
| Maintainers | adtkcn |
| Keywords | json, function |

## Links

- npm: https://www.npmjs.com/package/@adtkcn/jsonfunc
- npm.io page: https://npm.io/package/@adtkcn/jsonfunc

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.0.3 (latest) — 2023-02-24
- 1.0.2 — 2023-02-24
- 1.0.0 — 2023-02-24

## README

# 功能
实现序列化json时包含函数，支持普通函数、箭头函数、函数简写

# 只有两个函数,都只有一个参数

1. stringify() 将对象转字符串

2. parse() 将字符串转对象
 
会尝试将带有`function`，`=>`，`key:key(`字符的解析为函数
 

```js
import jsonfunc from "@adtkcn/jsonfunc";

var str = jsonfunc.stringify({
    a: 1,
    b() {
        console.log('b');
    },
    c(a, b) {
        console.log('c', a, b);
    },
    d: function () {
        console.log('d');
    },
    e: function (c, d) {
        console.log(c, d);
    },
    f: () => {
        console.log('f');
    },
    g: (a, b, c) => {
        console.log('g', a, b, c);
    },
    h: (a, b, c) => console.log('h', a, b, c)
})

var obj = jsonfunc.parse(str)
console.log(obj);
obj.b();
obj.c(1, 2);
obj.d();
obj.e(1, 2);
obj.f();
obj.g(1, 2, 3);
obj.h(1, 2, 3);
```

---
_Source: https://npm.io/package/@adtkcn/jsonfunc · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
