Skip to content

Commit b56e725

Browse files
committed
readme
1 parent 0f99c9b commit b56e725

File tree

3 files changed

+51
-8
lines changed

3 files changed

+51
-8
lines changed

README.md

+21-8
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313

1414
## Features
1515

16-
### Features
17-
1816
- **🛠️ Extended Serialization**: Converts JSON to JavaScript objects, supporting output, such as properties without quotes, not typically handled by standard JSON.
1917

2018
- **⚙️ Customizable**: Offers various options to customize the output, making it suitable for different use cases. Tailor the serialization process to meet your specific requirements.
@@ -35,23 +33,38 @@ yarn add strfy-js
3533

3634
Import `jsStringify` from `strfy-js` and use it to serialize JavaScript objects:
3735

38-
```javascript
36+
```js
3937
import { jsStringify } from 'strfy-js';
4038

4139
const obj = {
42-
name: "Alice",
43-
details: {
44-
age: 30,
45-
hobbies: ['reading', 'cycling']
46-
}
40+
"$schema": "schema.json",
41+
"chain_id": "cosmos-1",
42+
"logo_URIs": {
43+
"png": "cosmos.png"
44+
},
45+
"binaries": {
46+
"linux/amd64": "cosmos-bin.tar.gz"
47+
}
4748
};
4849

4950
const options = {
5051
space: 2,
52+
camelCase: true,
5153
quotes: 'single'
5254
};
5355

5456
console.log(jsStringify(obj, options));
57+
// OUTPUT:
58+
{
59+
$schema: 'schema.json',
60+
chainId: 'cosmos-1',
61+
logoURIs: {
62+
png: 'cosmos.png'
63+
},
64+
binaries: {
65+
"linux/amd64": 'cosmos-bin.tar.gz'
66+
}
67+
}
5568
```
5669

5770
## Options
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`chain 1`] = `
4+
"{
5+
$schema: 'schema.json',
6+
chainId: 'cosmos-1',
7+
logoURIs: {
8+
png: 'cosmos.png'
9+
},
10+
binaries: {
11+
"linux/amd64": 'cosmos-bin.tar.gz'
12+
}
13+
}"
14+
`;

__tests__/odd-props.test.ts

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { jsStringify } from "../src";
2+
3+
const chain = {
4+
"$schema": "schema.json",
5+
"chain_id": "cosmos-1",
6+
"logo_URIs": {
7+
"png": "cosmos.png"
8+
},
9+
"binaries": {
10+
"linux/amd64": "cosmos-bin.tar.gz"
11+
}
12+
};
13+
14+
it('chain', () => {
15+
expect(jsStringify(chain, { camelCase: true, space: 2 })).toMatchSnapshot();
16+
});

0 commit comments

Comments
 (0)