File tree Expand file tree Collapse file tree 3 files changed +51
-11
lines changed Expand file tree Collapse file tree 3 files changed +51
-11
lines changed Original file line number Diff line number Diff line change @@ -319,7 +319,8 @@ Result:
319319### Change key case
320320
321321``` php
322- use DragonCode\Contracts\Pretty\Arr\Caseable;use DragonCode\PrettyArray\Services\Formatter;
322+ use DragonCode\Contracts\Pretty\Arr\Caseable;
323+ use DragonCode\PrettyArray\Services\Formatter;
323324
324325$service = Formatter::make();
325326$service->setCase(Caseable::PASCAL_CASE);
@@ -363,7 +364,8 @@ The following options are available:
363364### Storing file
364365
365366``` php
366- use DragonCode\PrettyArray\Services\File;use DragonCode\PrettyArray\Services\Formatter;
367+ use DragonCode\PrettyArray\Services\File;
368+ use DragonCode\PrettyArray\Services\Formatter;
367369
368370$service = Formatter::make();
369371
@@ -397,6 +399,44 @@ return [
397399];
398400```
399401
402+ #### As JSON
403+
404+ ``` php
405+ use DragonCode\PrettyArray\Services\File;
406+ use DragonCode\PrettyArray\Services\Formatter;
407+
408+ $service = Formatter::make();
409+
410+ $service->asJson();
411+
412+ $formatted = $service->raw($array);
413+
414+ File::make($formatted)
415+ ->store('foo.json');
416+ ```
417+
418+ Result in stored file ` foo.json ` :
419+
420+ ``` json
421+ {
422+ "foo" : 1 ,
423+ "bar" : 2 ,
424+ "baz" : 3 ,
425+ "qwerty" : " qaz" ,
426+ "baq" : {
427+ "0" : " qwe" ,
428+ "1" : " rty" ,
429+ "asd" : " zxc"
430+ },
431+ "asdfgh" : {
432+ "foobarbaz" : " qwe" ,
433+ "2" : " rty" ,
434+ "qawsed" : " zxc"
435+ },
436+ "2" : " 'iop'"
437+ }
438+ ```
439+
400440## License
401441
402442This package is licensed under the [ MIT License] ( LICENSE ) .
Original file line number Diff line number Diff line change @@ -62,7 +62,7 @@ protected function value($value): mixed
6262 return $ this ->prepare ($ value );
6363 }
6464
65- return $ this -> castValue ( $ value) ;
65+ return $ value ;
6666 }
6767
6868 protected function encode (mixed $ value ): string
Original file line number Diff line number Diff line change 22 "foo": 1,
33 "bar": 2,
44 "baz": 3,
5- "qwe rty": "' qaz' ",
5+ "qwe rty": "qaz",
66 "baq": {
7- "0": "' qwe' ",
8- "1": "' rty' ",
9- "asd": "' zxc' "
7+ "0": "qwe",
8+ "1": "rty",
9+ "asd": "zxc"
1010 },
1111 "asd fgh": {
12- "foo bar baz": "' qwe' ",
13- "2": "' rty' ",
14- "qaw sed": "' zxc' "
12+ "foo bar baz": "qwe",
13+ "2": "rty",
14+ "qaw sed": "zxc"
1515 },
16- "2": "' iop' "
16+ "2": "iop"
1717}
You can’t perform that action at this time.
0 commit comments