Skip to content

Commit 3d6251f

Browse files
authored
Merge pull request #6 from SecJS/feat/len-json-api
fix: Json class docs in README
2 parents 02c86ef + 9458fa6 commit 3d6251f

File tree

4 files changed

+33
-2
lines changed

4 files changed

+33
-2
lines changed

README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,37 @@ yarn add @secjs/utils
2525

2626
## Classes Usage
2727

28+
### Json
29+
30+
> Use Json to parse json without errors and more.
31+
32+
```js
33+
import { Json } from '@secjs/utils'
34+
35+
const json = new Json()
36+
37+
const data = [
38+
{
39+
hello: 'hello',
40+
world: 'world',
41+
},
42+
]
43+
44+
json.isArrayOfObjects(data) // true
45+
json.isArrayOfObjects([]) // false
46+
json.isArrayOfObjects([1, 2, 3]) // false
47+
48+
const textWithJsons = 'string with a json inside of it {"text":"hello"} and one more json {"hello":"world"}'
49+
50+
json.getJson(textWithJsons) // ['{"text":"hello"}', '{"hello":"world"}']
51+
52+
const text = 'a string that is not a valid JSON'
53+
54+
json.parse(text) // null
55+
```
56+
57+
---
58+
2859
### Route
2960

3061
> Use Route to manipulate paths, getParams, getQueryParams, create route matcher RegExp etc.

index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
export * from './src/Classes/Json'
12
export * from './src/Classes/Token'
23
export * from './src/Classes/Clean'
34
export * from './src/Classes/Route'

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@secjs/utils",
3-
"version": "1.3.1",
3+
"version": "1.3.2",
44
"description": "",
55
"scripts": {
66
"build": "tsc",

tests/Classes/json.spec.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ describe('\n Json Class', () => {
2424
const text =
2525
'this is a string with a json inside of it {"text":"hello"} and one more json {"hello":"world"}'
2626

27-
console.log(json.getJson(text))
2827
expect(json.getJson(text)).toStrictEqual([
2928
'{"text":"hello"}',
3029
'{"hello":"world"}',

0 commit comments

Comments
 (0)