定制 arif-un/jcof 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

arif-un/jcof

最新稳定版本:1.0.2

Composer 安装命令:

composer require arif-un/jcof

包简介

Compress JSON in half

README 文档

README

A more efficient way to represent JSON-style objects.

About

JCOF tries to be a drop-in replacement for JSON, with most of the same semantics, but with a much more compact representation of objects. The main way it does this is to introduce a string table at the beginning of the object, and then replace all strings with indexes into that string table. It also employs a few extra tricks to make objects as small as possible, without losing the most important benefits of JSON. Most importantly, it remains a text-based, schemaless format.

Example JSON object (299 byte):****

{
	"people": [
		{"first-name": "Bob", "age": 32, "occupation": "Plumber", "full-time": true},
		{"first-name": "Alice", "age": 28, "occupation": "Programmer", "full-time": true},
		{"first-name": "Bernard", "age": 36, "occupation": null, "full-time": null},
		{"first-name": "El", "age": 57, "occupation": "Programmer", "full-time": false}
	]
}

Coverted JCOF object (134 byte) 55% lower :

Programmer;"age""first-name""full-time""occupation";
{"people"[(0,iw"Bob"b"Plumber")(0,is"Alice"b,s0)(0,iA"Bernard"n,n)(0,iV"El"B,s0)]}

Benchmark

json-vs-jcof-benchmark

Install

You can install Jcof through Composer:

composer require arif-un/jcof

Usage

stringify PHP associative array (json_encode)

use Jcof;

$jsonString = file_get_contents(__DIR__ . '/madrid.json');

$dataAssocArray = json_decode($jsonString, true); // covert to an associative array

$jcofCompressedStr = Jcof::stringify($dataAssocArray); // compressed string

convert back to JSON

use Jcof;

$dataAssocArray = Jcof::parse($jcofCompressedStr); // covert jcof compressed string to associative array

$jsonData = json_encode($dataAssocArray); // coverted json

Other language implementation

  • JCOF Javascript NPM


#### This repository is php implementation of [javascript version](https://github.com/mortie/jcof).

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-09-26

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固