# zhf.query-string

> 解析URL查询字符串

Latest version **1.0.5** (published 2018-12-16) · ISC license · 0 weekly downloads

## Install

```sh
npm install zhf.query-string
pnpm add zhf.query-string
yarn add zhf.query-string
bun add zhf.query-string
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.5 |
| Published | 2018-12-16 |
| First published | 2018-03-02 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 12.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | zhouhuafei |

## Links

- npm: https://www.npmjs.com/package/zhf.query-string
- Repository: https://github.com/zhouhuafei/zhf.query-string
- Homepage: https://github.com/zhouhuafei/zhf.query-string#readme
- Issues: https://github.com/zhouhuafei/zhf.query-string/issues
- npm.io page: https://npm.io/package/zhf.query-string

## Recent versions

- 1.0.5 (latest) — 2018-12-16
- 1.0.4 — 2018-11-06
- 1.0.3 — 2018-03-19
- 1.0.2 — 2018-03-02
- 1.0.1 — 2018-03-02
- 1.0.0 — 2018-03-02

## README

# 解析URL查询字符串
```
const queryString = require('zhf.query-string');

console.log(queryString.queryStringify({username: 'hello world'})); // username=hello%20world
console.log(queryString.queryParse('#a=1&b=2')); // {a: '1', b: '2'}
console.log(queryString.queryParse('?a=1&b=2')); // {a: '1', b: '2'}
console.log(queryString.queryParse('a=1&b=2')); // {a: '1', b: '2'}
console.log(queryString.queryStringify({a: 1, b: 2})); // 'a=1&b=2'
console.log(queryString.queryStringify({a: 1, b: ['x', 'y', 'z'], c: {n: 'n', m: 'm'}})); // 'a=1&b=%5B%22x%22%2C%22y%22%2C%22z%22%5D&c=%7B%22n%22%3A%22n%22%2C%22m%22%3A%22m%22%7D'
console.log(queryString.queryParse('a=1&b=%5B%22x%22%2C%22y%22%2C%22z%22%5D&c=%7B%22n%22%3A%22n%22%2C%22m%22%3A%22m%22%7D')); // {a: '1', b: ['x', 'y', 'z'], c: {n: 'n', m: 'm'}}
console.log(queryString.queryParse('a={"sentence":"hello world"}&b=["x","y","z"]')); // {a: {sentence: 'hello world'}, b: ['x', 'y', 'z']}
console.log(queryString.queryParse('a={sentence:"hello world"}&b=["x","y","z"]')); // {a: '{sentence:"hello world"}', b: ['x', 'y', 'z']} 因为 {sentence:"hello world"} 不是规范的json格式，导致JSON.parse解析不了，所以我进行了直接赋值
```

# 建议使用这个，他这个比我写的好多了
* https://www.npmjs.com/package/query-string

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