# string-to-json

> Convert string with dot notation as a key into json object

Latest version **0.1.0** (published 2013-07-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install string-to-json
pnpm add string-to-json
yarn add string-to-json
bun add string-to-json
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2013-07-09 |
| First published | 2013-07-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | * |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 12 |
| Author | Murvin Lai |
| Maintainers | murvinlai |
| Keywords | string to json, string, json, dot notation, convert |

## Links

- npm: https://www.npmjs.com/package/string-to-json
- Repository: https://github.com/murvinlai/string-to-json
- npm.io page: https://npm.io/package/string-to-json

## Dependencies (1)

- [underscore-x](https://npm.io/package/underscore-x.md) >= 0.1.0

## 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

- 0.1.0 (latest) — 2013-07-09

## README

string-to-json
==============

Convert a string representation of dot-notion key into json format object.
It is particularly useful for converting req.query with dot notation as the key into json.
```js
e.g. a http query like this: 

canada.bc.yvr.name=Vancouver&canada.bc.yvr.id=1234&usa.ny.nyc.name=New%20York

or a req.query like this: 

req.query = { "canada.bc.yvr.name":"Vancouver", "canada.bc.yvr.id":1234, "usa.ny.nyc.name"="New%20York" }

will result in: {"canada":{"bc":{"yvr":{"name":"Vancouver","id":"1234"}}},"usa":{"ny":{"nyc":{"name":"New York"}}}}

```

-------------


## Purpose


## Installation
    $ npm install string-to-json

## Quick Start

```js
    var str2json = require('string-to-json');
    
    var output = str2json.convert({"abc.def.g":2});

    // result: output = {'abc':{'def':{{'g':2}}}


   var output = str2json.convert({"abc.def.g":2, "abc.def.h":[1,2,3], "abc.def.i":"xxxxx"});

   // result: output = {abc:{def:{g:2, h:[1,2,3], i:"xxxxx"}}}

```

## Upcoming

- Take input as JSON format in entire string like this:  '{"abc.def.g":123}' which passes JSON.parse();
- Take input as http query like this: 'abc.def.g=123&abc.def.h=[1,2,3]&abc.def.i=xxxxx'

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