承接 samluvanda/json 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

samluvanda/json

最新稳定版本:v1.0.0

Composer 安装命令:

composer require samluvanda/json

包简介

A powerful and fluent JSON utility class for PHP with dot-notation access and custom exception handling.

README 文档

README

A powerful and fluent JSON utility class for PHP with dot-notation access and custom exception handling.

🚀 Features

  • Dot-notation access (get('user.name'))
  • Fluent method chaining (set()->remove()->toJson())
  • Safe JSON parsing and encoding with exception support
  • Supports both associative arrays and objects
  • PSR-4 autoloading, modern PHP 8.1+

📦 Installation

Install via Composer:

composer require samluvanda/json

🧱 Usage Example

use Json\Json;

$json = new Json('{"user": {"name": "Alice"}}');

echo $json->get('user.name'); // Alice

$json->set('user.age', 30)
     ->remove('user.name');

echo $json->toJson(); // {"user":{"age":30}}

📘 API Overview

Method Description
__construct($json) Load JSON string
Json::parse($json) Decode JSON string into PHP data
Json::stringify($val) Encode PHP value into JSON string
Json::isValid($json) Validate JSON string
get($path, $default) Dot-notation key access
set($path, $value) Set nested key
has($path) Check if path exists
remove($path) Remove nested key
toJson() Convert to JSON string
all() Get raw PHP structure

🤝 Contributing

Contributions are welcome! If you'd like to improve this library:

  1. Fork the repository
  2. Create a new branch
  3. Make your changes
  4. Submit a pull request

Please ensure your code follows PSR standards and includes relevant tests where applicable.

📄 License

This project is licensed under the MIT License.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-06-22