iamjohndev/json-reform 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

iamjohndev/json-reform

Composer 安装命令:

composer require iamjohndev/json-reform

包简介

A simple PHP Library that can read and format JSON data.

README 文档

README

A simple PHP library for reading, formatting and getting values of a JSON data.

Installation

Install via Composer: composer require iamjohndev/json-reform:dev-main

Usage

    use iamjohndev\JSONReform;
    
    // Read JSON data from a string
    $json = '{"name": "John", "age": 30}';
    $reader = new JSONReform($json);
    
    // Get a value from the JSON data
    $name = $reader->getValue('name'); // "John"
    
    // Format the JSON data
    $prettyJson = $reader->format('pretty'); // "{\n    "name": "John",\n    "age": 30\n}"
    
    // Read JSON data from a file
    $reader = JSONReform::fromFile('data.json');
    
    // Get a nested value from the JSON data
    $value = $reader->getValue('data.persons.0.name'); // "John"

API

JSONReform::__construct(string $json)
// Creates a new JSONReform instance from a JSON string.

JSONReform::fromFile(string $path)
// Creates a new JSONReform instance from a JSON file.

JSONReform::getValue(string $path, mixed $default = null): mixed
// Gets the value at the specified path in the JSON data.

JsonReform::fromHTTPRequestBody();
// Creates a new JsonReform instance from an HTTP Request Body

JSONReform::format(string $format = 'json'): string
// Returns the JSON string in the specified format.

统计信息

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

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-04-20