Skip to content

Commit

Permalink
readme
Browse files Browse the repository at this point in the history
  • Loading branch information
pyramation committed Apr 13, 2024
1 parent 0f99c9b commit b56e725
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 8 deletions.
29 changes: 21 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

## Features

### Features

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

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

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

```javascript
```js
import { jsStringify } from 'strfy-js';

const obj = {
name: "Alice",
details: {
age: 30,
hobbies: ['reading', 'cycling']
}
"$schema": "schema.json",
"chain_id": "cosmos-1",
"logo_URIs": {
"png": "cosmos.png"
},
"binaries": {
"linux/amd64": "cosmos-bin.tar.gz"
}
};

const options = {
space: 2,
camelCase: true,
quotes: 'single'
};

console.log(jsStringify(obj, options));
// OUTPUT:
{
$schema: 'schema.json',
chainId: 'cosmos-1',
logoURIs: {
png: 'cosmos.png'
},
binaries: {
"linux/amd64": 'cosmos-bin.tar.gz'
}
}
```

## Options
Expand Down
14 changes: 14 additions & 0 deletions __tests__/__snapshots__/odd-props.test.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`chain 1`] = `
"{
$schema: 'schema.json',
chainId: 'cosmos-1',
logoURIs: {
png: 'cosmos.png'
},
binaries: {
"linux/amd64": 'cosmos-bin.tar.gz'
}
}"
`;
16 changes: 16 additions & 0 deletions __tests__/odd-props.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { jsStringify } from "../src";

const chain = {
"$schema": "schema.json",
"chain_id": "cosmos-1",
"logo_URIs": {
"png": "cosmos.png"
},
"binaries": {
"linux/amd64": "cosmos-bin.tar.gz"
}
};

it('chain', () => {
expect(jsStringify(chain, { camelCase: true, space: 2 })).toMatchSnapshot();
});

0 comments on commit b56e725

Please sign in to comment.