-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
49 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,7 @@ | |
|
||
## Usages | ||
|
||
#### In html | ||
### In html | ||
|
||
```html | ||
<script src="https://unpkg.com/[email protected]/fmt2json.min.js"></script> | ||
|
@@ -31,10 +31,41 @@ | |
const jsonString = fmt2json(source); | ||
console.log(jsonString); | ||
// => | ||
`{ | ||
"zjson": "ZJSON", | ||
"description:"Online json formatter", | ||
"version": "v4.1.8", | ||
"updateTime": "2018-11-23", | ||
"url": "https://zjson.net", | ||
"project": "https://github.com/CN-Tower/zjson", | ||
"language": [ | ||
"中文(简体)", | ||
"English" | ||
], | ||
"keywords": [ | ||
"zjson", | ||
"json formatter" | ||
], | ||
"content": { | ||
"array": [ | ||
"element 001", | ||
"element 002" | ||
], | ||
"boolean": true, | ||
"null": null, | ||
"number": 123, | ||
"string": "Hello World", | ||
"object": { | ||
"property": "value", | ||
"key": "val" | ||
} | ||
} | ||
}` | ||
</script> | ||
``` | ||
|
||
#### In javascript | ||
### In javascript | ||
|
||
Run: `npm install format-to-json --save`; | ||
|
||
|
@@ -47,7 +78,7 @@ const fmtInfo = fmt2json(source, { withDetails: true }); | |
console.log(fmtInfo.result); | ||
``` | ||
|
||
In js Result: | ||
Output: | ||
|
||
```js | ||
{ | ||
|
@@ -80,11 +111,11 @@ In js Result: | |
' "key": "val"\r\n' + | ||
' }\r\n' + | ||
' }', | ||
fmtType: 'success', | ||
fmtSign: 'scc', | ||
fmtType: 'danger', | ||
fmtSign: 'end', | ||
fmtLines: 29, | ||
fmtTime: 1.1812089681625366, | ||
message: 'Success formated 29 lines!', | ||
fmtTime: 1.0678750276565552, | ||
message: 'Expect a comma or a "}" in line: 29', | ||
errFormat: true, | ||
errIndex: 29, | ||
errNear: '...": "val"\\n }\\n }>>>>>>', | ||
|
@@ -127,8 +158,8 @@ interface FormatResult { | |
message: string; | ||
errFormat: boolean; | ||
errIndex: number; | ||
errExpect: string; | ||
errNear: string; | ||
errExpect: string; | ||
} | ||
``` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/** | ||
* @license | ||
* format-to-json v3.0.1 | ||
* format-to-json v3.0.2 | ||
* GitHub Repository <https://github.com/CN-Tower/format-to-json> | ||
* Released under MIT license <https://github.com/CN-Tower/format-to-json/blob/master/LICENSE> | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters