承接 aayinde/json-office 相关项目开发

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

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

aayinde/json-office

Composer 安装命令:

composer require aayinde/json-office

包简介

Modern & Simplified Json Reader and Writer

README 文档

README

A Simple easy to use Json File Reader and Writer with minimal setup.

tests

Installation

composer require aayinde/json-office

Usage

JsonArrayWriter

Return to steam reader

<?php
use Aayinde\JsonOffice\Writer\JsonArrayWriter;

$objJsonWriter = new JsonWriter();
$objJsonWriter->getInstanceJsonWriter()
    ->setInput($array)
    ->resultOutput();

Input:

$array = [
    'default' => [
        'config' => [
            'host' => 'localhost',
            'port' => 3306,
            'username' => "root",
            'password' => "root",
            'schema' => "test",
            'prefix' => "test",
            'socket' => null,
            'engine' => 'InnoDB',
            'charset' => 'utf8mb4',
            'collation' => 'utf8mb4_general_ci',
            'timezone' => '+00:00',
            'ssl' => [
                'enabled' => false,
                'verify' => true,
                'key' => null,
                'cert' => null,
                'ca' => null,
                'capath' => null,
                'cipher' => null
            ],
            'failover' => [],
            'options' => [
                MYSQLI_OPT_CONNECT_TIMEOUT => 10,
                MYSQLI_OPT_INT_AND_FLOAT_NATIVE => true,
                MYSQLI_OPT_LOCAL_INFILE => 1
            ],
            'report' => MYSQLI_REPORT_ALL & ~ MYSQLI_REPORT_INDEX
        ],
        'logger_instance' => 'default'
    ]
];

Output:

{"default":{"config":{"host":"localhost","port":3306,"username":"root","password":"root","schema":"test","prefix":"test","socket":null,"engine":"InnoDB","charset":"utf8mb4","collation":"utf8mb4_general_ci","timezone":"+00:00","ssl":{"enabled":false,"verify":true,"key":null,"cert":null,"ca":null,"capath":null,"cipher":null},"failover":[],"options":{"0":10,"201":true,"8":1},"report":251},"logger_instance":"default"}}

JsonArrayWriter

Save to File.

<?php
use Aayinde\JsonOffice\Writer\JsonArrayWriter;

$objJsonWriter = new JsonWriter();
$objJsonWriter->getInstanceJsonWriter()
    ->setInput($array)
    ->saveToFile("test"));


Output:

test.json

Additional Parameters

Pretty Output

usage

<?php
$objJsonWriter = new JsonWriter();
$objJsonWriter->getInstanceJsonWriter()
    ->setInput($array)->useToPrettyPrint()
    ->resultOutput();

Output:

{
    "default": {
        "config": {
            "host": "localhost",
            "port": 3306,
            "username": "root",
            "password": "root",
            "schema": "test",
            "prefix": "test",
            "socket": null,
            "engine": "InnoDB",
            "charset": "utf8mb4",
            "collation": "utf8mb4_general_ci",
            "timezone": "+00:00",
            "ssl": {
                "enabled": false,
                "verify": true,
                "key": null,
                "cert": null,
                "ca": null,
                "capath": null,
                "cipher": null
            },
            "failover": [],
            "options": {
                "0": 10,
                "201": true,
                "8": 1
            },
            "report": 251
        },
        "logger_instance": "default"
    }
}

Additional Methods

->useToPrettyPrint()

->useConvertAmpsToHexValue()

->useConvertAposToHexValue()

->useConvertForceObject()

->useConvertNumericCheck()

->useConvertQuoteToHexValue()

->useConvertTagsToHexValue()

->usePreserveZeroFraction()

->usePartialOutputOnError()

->useUnescapedLineTerminators()

->useUnescapedSlashes()

->useUnescapedUnitcode()

JsonReader

JsonFileReader

Read a Json file

<?php
use Aayinde\JsonOffice\JsonReader;

$objJsonReader = new JsonReader();
$objJsonReader->getInstanceJsonFileReader()
    ->setReader("test.json")
    ->result();

Output

object(stdClass)[75]
  public 'default' => 
    object(stdClass)[76]
      public 'config' => 
        object(stdClass)[78]
          public 'host' => string 'localhost' (length=9)
          public 'port' => int 3306
          public 'username' => string 'root' (length=4)
          public 'password' => string 'root' (length=4)
          public 'schema' => string 'test' (length=4)
          public 'prefix' => string 'test' (length=4)
          public 'socket' => null
          public 'engine' => string 'InnoDB' (length=6)
          public 'charset' => string 'utf8mb4' (length=7)
          public 'collation' => string 'utf8mb4_general_ci' (length=18)
          public 'timezone' => string '+00:00' (length=6)
          public 'ssl' => 
            object(stdClass)[77]
              public 'enabled' => boolean false
              public 'verify' => boolean true
              public 'key' => null
              public 'cert' => null
              public 'ca' => null
              public 'capath' => null
              public 'cipher' => null
          public 'failover' => 
            array (size=0)
              empty
          public 'options' => 
            object(stdClass)[74]
              public '0' => int 10
              public '201' => boolean true
              public '8' => int 1
          public 'report' => int 251
      public 'logger_instance' => string 'default' (length=7)

JsonStringReader

Read a Json String

Usage

<?php
use Aayinde\JsonOffice\JsonReader;
$objJsonReader = new JsonReader();
$objJsonReader->getInstanceJsonStringReader()
    ->setReader($readerInput)
    ->result();

Input

{"default":{"config":{"host":"localhost","port":3306,"username":"root","password":"root","schema":"test","prefix":"test","socket":null,"engine":"InnoDB","charset":"utf8mb4","collation":"utf8mb4_general_ci","timezone":"+00:00","ssl":{"enabled":false,"verify":true,"key":null,"cert":null,"ca":null,"capath":null,"cipher":null},"failover":[],"options":{"0":10,"201":true,"8":1},"report":251},"logger_instance":"default"}}

Output

object(stdClass)[75]
  public 'default' => 
    object(stdClass)[76]
      public 'config' => 
        object(stdClass)[78]
          public 'host' => string 'localhost' (length=9)
          public 'port' => int 3306
          public 'username' => string 'root' (length=4)
          public 'password' => string 'root' (length=4)
          public 'schema' => string 'test' (length=4)
          public 'prefix' => string 'test' (length=4)
          public 'socket' => null
          public 'engine' => string 'InnoDB' (length=6)
          public 'charset' => string 'utf8mb4' (length=7)
          public 'collation' => string 'utf8mb4_general_ci' (length=18)
          public 'timezone' => string '+00:00' (length=6)
          public 'ssl' => 
            object(stdClass)[77]
              public 'enabled' => boolean false
              public 'verify' => boolean true
              public 'key' => null
              public 'cert' => null
              public 'ca' => null
              public 'capath' => null
              public 'cipher' => null
          public 'failover' => 
            array (size=0)
              empty
          public 'options' => 
            object(stdClass)[74]
              public '0' => int 10
              public '201' => boolean true
              public '8' => int 1
          public 'report' => int 251
      public 'logger_instance' => string 'default' (length=7)
      

Additional Methods

->useObjectAsArray()

->useBigIntAsString()

->useIgnoreInvalidUtf8()

->useInvalidUtf8Substitute()

aayinde/json-office 适用场景与选型建议

aayinde/json-office 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 19 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 10 月 13 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「php」 「json」 「file」 「library」 「array」 「writer」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 aayinde/json-office 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 aayinde/json-office 我们能提供哪些服务?
定制开发 / 二次开发

基于 aayinde/json-office 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-10-13