# query-to-obj

> Converts a query string to a javascript object

Latest version **1.0.2** (published 2018-02-16) · 0 weekly downloads

## Install

```sh
npm install query-to-obj
pnpm add query-to-obj
yarn add query-to-obj
bun add query-to-obj
```

## 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.2 |
| Published | 2018-02-16 |
| First published | 2016-11-22 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 205.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | kristoferk |
| Maintainers | kristoferk |
| Keywords | javascript |

## Links

- npm: https://www.npmjs.com/package/query-to-obj
- Repository: https://github.com/kristoferk/query-to-obj
- Homepage: https://github.com/kristoferk/query-to-obj#readme
- Issues: https://github.com/kristoferk/query-to-obj/issues
- npm.io page: https://npm.io/package/query-to-obj

## Recent versions

- 1.0.2 (latest) — 2018-02-16
- 1.0.1 — 2016-11-22
- 1.0.0 — 2016-11-22

## README

# query-to-obj

![](https://api.travis-ci.org/kristoferk/query-to-obj.svg?branch=master)

Converts a javascript object to a url query string. Supports lists and nested objects.


## Installation
```shell
npm install query-to-obj --save
```

## Usage
```js
import queryToObj from 'query-to-obj';
const obj = queryToObj("Id=3&Name=Example&List=a&List=b&Sub.Prop=S"); 

//Result: 
// { 
//     Id: 3, 
//     Name: 'Example', 
//     List: ['a', 'b'], 
//     Sub: { Prop: 'S' } 
// }

```



## Optional settings
```js
import queryToObj from 'query-to-obj';
const obj = queryToObj("Id=3&Name=Example&EmptyKey=", {
    skipEmptyValues: false,    //If empty string values should be included in object, Default: false 
    keyCase: 'camelCase',      //Convert keys to camelCase, also support for 'PascalCase', 'snake_case' and 'None'. Default: 'None'
    valueCase: 'lowercase',    //Convert values to lowercase, also support for 'UPPERCASE' and 'None'. Default: 'None'
    skipCast: true,            //If values should be casted to other types then strings, Default: false
    decode: true               //If values should be url decoded, Default: false   
}); 

//Result: 
// { 
//     id: '3', 
//     name: 'example'
// }

```



## Tests
```shell
npm test
```


## Release History

* 1.0.0 Initial release
* 1.0.1 Add some optional settings for manipulating case on keys and values
* 1.0.2 Fixed issue with decoding keys [#1](https://github.com/kristoferk/query-to-obj/issues/1)  (Thanks to Eli Doran for reporting issue)

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