Skip to content

Commit c763fba

Browse files
committed
docs: add example json
1 parent 2209274 commit c763fba

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

README.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
- Also strips trailing comma at the end of array or object, eg:
1515
- `[1,2,,]` => `[1,2]`
1616
- `{"x":1,,}` => `{"x":1}`
17+
- Handles literal LF (newline/linefeed) within string notation
1718

1819
## Installation
1920
```bash
@@ -56,3 +57,54 @@ Comment::parse($json, true);
5657
# Or use file directly
5758
Comment::parseFromFile('/path/to/file.json', true);
5859
```
60+
61+
### Example
62+
63+
An example JSON that this library can parse:s
64+
65+
```json
66+
{
67+
"name": "adhocore/json-comment",
68+
"description": "JSON comment stripper library for PHP.
69+
There is literal line break just above this line but that's okay",
70+
"type":/* This is creepy comment */ "library",
71+
"keywords": [
72+
"json",
73+
"comment",
74+
// Single line comment, Notice the comma below:
75+
"strip-comment",
76+
],
77+
"license": "MIT",
78+
/*
79+
* This is a multiline comment.
80+
*/
81+
"authors": [
82+
{
83+
"name": "Jitendra Adhikari",
84+
"email": "jiten.adhikary@gmail.com",
85+
},
86+
],
87+
"autoload": {
88+
"psr-4": {
89+
"Ahc\\Json\\": "src/",
90+
},
91+
},
92+
"autoload-dev": {
93+
"psr-4": {
94+
"Ahc\\Json\\Test\\": "tests/",
95+
},
96+
},
97+
"require": {
98+
"php": ">=7.0",
99+
"ext-ctype": "*",
100+
},
101+
"require-dev": {
102+
"phpunit/phpunit": "^6.5 || ^7.5 || ^8.5",
103+
},
104+
"scripts": {
105+
"test": "phpunit",
106+
"echo": "echo '// This is not comment'",
107+
"test:cov": "phpunit --coverage-text",
108+
},
109+
}
110+
```

0 commit comments

Comments
 (0)