manojkiran / jsonwriter
读取和写入PHP数组或Laravel Collection到JSON文件
dev-master
2019-07-03 06:55 UTC
Requires
- php: ^7.1
- illuminate/support: 5.7.*|5.8.*
Requires (Dev)
- orchestra/testbench: 3.8.*
- phpunit/phpunit: ^7.0
This package is auto-updated.
Last update: 2024-09-29 05:21:58 UTC
README
读取和写入PHP数组| Laravel Collection | EloquentCollection到json文件
安装
您可以通过composer安装此包
composer require manojkiran/jsonwriter
导入
use Manojkiran\JsonWriter\Facades\JsonWriter;
用法
写入
将内容写入Json
//get the List of Active users $usersList = User::where('status','=','Active')->get(); //getting the path where the file is available $jsonFilePath = storage_path('jsonWriter.json'); //loading the Json File and Writing the Content to it $writeToJson = JsonWriter::load( $jsonFilePath) ->write($usersList);
将内容写入Json(强制)
//by default the duplicate Content Will Not to Writtent To Json File(To Reduce the data Size) //array of the Projects by Taylor Otwell $laravel = ['name' => 'Taylor Otwell','developed' => ['Laravel','Lumen','Telescope','Nova']]; //getting the path where the file is available $jsonFilePath = storage_path('jsonWriter.json'); //loading the Json File and Writing the Content to it $writeToJson = JsonWriter::load( $jsonFilePath) ->write($laravel,true);
读取
//get the List of Active users $usersList = User::where('status','=','Active')->get(); //getting the path where the file is available $jsonFilePath = storage_path('jsonWriter.json'); //loading the Json File and Writing the Content to it $writeToJson = JsonWriter::load( $jsonFilePath) ->parseFile();
测试
composer test
变更日志
有关最近更改的更多信息,请参阅变更日志。
贡献
有关详细信息,请参阅贡献指南。
安全
如果您发现任何安全问题,请通过manojkiran10031998@gmail.com发送电子邮件,而不是使用问题跟踪器。
鸣谢
许可证
MIT许可证(MIT)。有关更多信息,请参阅许可证文件。
Laravel Package Boilerplate
此包使用Laravel Package Boilerplate生成。