arturdoruch/json 问题修复 & 功能扩展

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

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

arturdoruch/json

Composer 安装命令:

composer require arturdoruch/json

包简介

JSON component

README 文档

README

  • Wraps JSON decoding and encoding actions into class. Handles decoding error.
  • Provides JSON syntax highlighting.

Installation

Install by running composer command composer require arturdoruch/json

Usage

Decode JSON

use ArturDoruch\Json\Json;
use ArturDoruch\Json\UnexpectedJsonException;

$jsonString = '';
// Decode JSON to array or stdClass object.
// If JSON is invalid `ArturDoruch\Json\UnexpectedJsonException` is thrown.
$json = new Json($jsonString);

// Get decoded JSON.
$json->getDecoded();

// Get encoded JSON with specified options like JSON_PRETTY_PRINT.
$json->getEncoded();

// Catch decoding exception
try {
    $json = new Json($jsonString);
} catch (UnexpectedJsonException $exception) {
    // Get decoded invalid JSON.
    $exception->getJson();
    // Get error code.
    $exception->getCode();
}

Highlight JSON syntax

use ArturDoruch\Json\JsonUtils;

// JSON string. 
$json = '{"string": "foo bar \"baz\"", "integer": 128, "float": -1.5678, "boolean": true, "null": null}';
$classPrefix = 'json';
$highlighted = JsonUtils::highlightSyntax($json, $classPrefix);

Define the following CSS styles to styling JSON code:

  • span.{classPrefix}-key {}
  • span.{classPrefix}-string {}
  • span.{classPrefix}-integer {}
  • span.{classPrefix}-float {}
  • span.{classPrefix}-boolean {}
  • span.{classPrefix}-null {}

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-07-02

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固