Skip to content

Commit 2847ee7

Browse files
Document the JSON handling also works when reading all available cookies
1 parent c089770 commit 2847ee7

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

‎README.md‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,18 +82,26 @@ When creating a cookie you can pass an Array or Object Literal instead of a stri
8282
Cookies.set('name', { foo: 'bar' });
8383
```
8484

85-
When reading a cookie with the default `Cookies.get()` api, you receive the stringified representation stored in the cookie:
85+
When reading a cookie with the default `Cookies.get` api, you receive the stringified representation stored in the cookie:
8686

8787
```javascript
8888
Cookies.get('name'); // => '{"foo":"bar"}'
8989
```
9090

91-
When reading a cookie with the `Cookies.getJSON()` api, you receive the parsed representation of the string stored in the cookie according to the `JSON.stringify` api (if available):
91+
```javascript
92+
Cookies.get(); // => { name: '{"foo":"bar"}' }
93+
```
94+
95+
When reading a cookie with the `Cookies.getJSON` api, you receive the parsed representation of the string stored in the cookie according to the `JSON.stringify` api (if available):
9296

9397
```javascript
9498
Cookies.getJSON('name'); // => { foo: 'bar' }
9599
```
96100

101+
```javascript
102+
Cookies.getJSON(); // => { name: { foo: 'bar' } }
103+
```
104+
97105
## RFC 6265
98106

99107
This project assumes [RFC 6265](http://tools.ietf.org/html/rfc6265#section-4.1.1) as a reference for everything. That said, some custom rules are applied in order to provide robustness and cross-browser compatibility.

0 commit comments

Comments
 (0)