fwhat/jsonmapper 问题修复 & 功能扩展

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

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

fwhat/jsonmapper

Composer 安装命令:

composer require fwhat/jsonmapper

包简介

json to php object

README 文档

README

功能

  • 实现从json生成对应的php对象
  • 支持对象嵌套
  • 支持object[],object[][] 多层级数组对象结构
  • 提供Map类, 区分array与map

性能

(JsonMapper 对象内置分析缓存, 一个进程内实例化一次效果最佳)

  • 简单对象 可生成 150000w+/s
  • 复杂对象 可生成 1w+/s

安装

composer require fwhat/jsonmapper

使用示例

use Fwhat\JsonMapper\JsonMapper;
class SetObject {
    public bool $bool;
    public int $int;
    public ?string $string = null;
    public array $arrayString;
    public array $arrayInt;
    public float $float;

    /**
     * @var array
     */
    public array $arrayWithDoc;

    public function setString (string $str) {
        $this->string = "from_set_".$str;
    }
}

$jsonStr = '{
  "bool": true,
  "int": 1,
  "string": "string",
  "arrayString": [
    "arrayString",
    "arrayString"
  ],
  "arrayInt": [
    "arrayInt",
    "arrayInt"
  ],
  "float": 1.23,
  "arrayWithDoc": ["arrayWithDoc"]
}';


$mapper = new JsonMapper;
$object = new SetObject();
$mapper->map($jsonStr, $object);

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-01-13

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固