Skip to content

Commit

Permalink
Add some documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Coles authored and Matt Coles committed Apr 30, 2016
1 parent 90da33f commit 37342ae
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,36 @@
# js-query-string [![Travis branch](https://img.shields.io/travis/Alpha-Atom/js-query-string/master.svg)](https://travis-ci.org/Alpha-Atom/js-query-string) [![Coverage Status](https://coveralls.io/repos/github/Alpha-Atom/js-query-string/badge.svg?branch=master)](https://coveralls.io/github/Alpha-Atom/js-query-string?branch=master)

Documentation to follow.
Simple Javascript module, with no dependencies, to serialise native JS objects to be used in URL parameters. Objects and arrays are seralised as JSON strings to allow for easy representation of nested objects.

Can be installed very simply with:

```
npm install js-query-string
```

Example usage:

```javascript
var jsq = require('js-query-string');

var qs_object = {
str: "mystr",
second_str: "myotherstr"
};

var qs_object2 = {
obj1: {
a: 1,
b: "string"
},
obj2: {
c: true,
b: [1,2]
}
};

console.log(jsq.convert(qs_object)); // ?str=mystr&second_str=myotherstr
console.log(jsq.convert(qs_object2)); // ?obj1=%7B%22a%22%3A1%2C%22b%22%3A%22string%22%7D&obj2=%7B%22c%22%3Atrue%2C%22b%22%3A%5B1%2C2%5D%7D
```

Parameters are also encoded for URLs. The following datatypes are supported: RegExp, Object, Array, Number, String, Boolean.

0 comments on commit 37342ae

Please sign in to comment.