定制 jsonmodifier/json 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

jsonmodifier/json

最新稳定版本:1.0.0

Composer 安装命令:

composer require jsonmodifier/json

包简介

PHP package allows developers to manipulate JSON files by performing data lookup and many other operations such as read, write, delete and update.

README 文档

README

JsonModifier is a PHP package designed to assist developers in manipulating JSON files. It offers a range of operations, including data lookup, reading, adding, deleting, and updating JSON data.

Table of Contents

Installation

Install the package via Composer:

composer require jsonmodifier/json

Usage

First, include the Composer autoload file and create a new instance of JsonModifier by providing the path to your JSON file:

require 'vendor/autoload.php';

use PhpJsonModifier\JsonModifier;

$json = new JsonModifier('path/to/your/jsonfile.json');

Retrieving Data

To retrieve all data from a specific index:

$data = $json->index('items')->get();

Updating Data

To update specific fields where a condition is met:

$update = $json->index('items')->update(
    ['id', '3'], // Condition: WHERE id = 3
    [
        ['unitprice' => '224.50'],
        ['color' => '#fff']
    ]
);

Adding Data

To add a new item to the JSON file:

$add = $json->index('items')->add([
    "id" => "10",
    "name" => "black shirt",
    "unitprice" => "150.00"
]);

Searching Data

To search for items matching specific criteria:

$search = $json->index('items')->search(['id' => '2'])->get();

To retrieve the first item that matches the criteria:

$search = $json->index('items')->search(['id' => '2'])->first();

Contributing

Contributions are welcome! Please fork the repository and submit a pull request with your proposed changes. Ensure that your code adheres to the project's coding standards and includes appropriate tests.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Note: Ensure that your JSON files are properly formatted to prevent errors. Here's an example of a valid JSON structure:

[
    {
        "items": [
            {
                "id": "1",
                "name": "original t-shirt",
                "unitprice": "240.00"
            },
            {
                "id": "2",
                "name": "Cotton Polo Shirt",
                "unitprice": "123.00"
            }
        ]
    }
]

统计信息

  • 总下载量: 18
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 11
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 11
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-02-06

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固