承接 mrbenosborne/json-unmarshal 相关项目开发

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

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

mrbenosborne/json-unmarshal

最新稳定版本:1.0.1

Composer 安装命令:

composer require mrbenosborne/json-unmarshal

包简介

A PHP 8 package for un-marshalling JSON data onto class properties.

README 文档

README

A PHP package for un-marshalling JSON data onto a class properties.

Build Latest Stable Version Latest Unstable Version License composer.lock

Install

Install via composer.

composer require mrbenosborne/json-unmarshal

Example

Below is an example of a Flight class, the full example can be found in the examples/ folder.

<?php

use JSON\Attributes\JSON;
use JSON\Unmarshal;

include '../vendor/autoload.php';
include 'FlightRoute.php';

/**
 * Class Flight
 */
class Flight
{
    #[JSON(field: 'airline')]
    public string $airlineName;

    #[JSON(field: 'aircraft.type')]
    public string $aircraftType;

    #[JSON(field: 'route', type: FlightRoute::class)]
    public array $route;
}

// Create a new flight class
$flight = new Flight();

// Load our JSON data from file
$jsonData = json_decode(file_get_contents('flight.json'), true);

// Unmarshal JSON
Unmarshal::decode($flight, $jsonData);

统计信息

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

GitHub 信息

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

其他信息

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