danharper/jsonx
最新稳定版本:v0.1.0
Composer 安装命令:
composer require danharper/jsonx
包简介
JSONx is an IBM standard for representing JSON as XML
README 文档
README
A library implementing IBM's standard format for representing JSON as XML. Provides support for both reading & writing of JSONx. The spec draft for JSONx can be found here.
WHY?! That was my initial reaction, too. However it's very useful when you're trying to integrate one system which speaks JSON with another which speaks XML, without having to make potentially large changes.
Installation
composer require danharper/jsonx
Usage
$jsonx = new danharper\JSONx\JSONx; $jsonx->toJSONx([ 'foo' => [ 'bar', true, 2, 3.14, null, [], (object) [] ] ]); /* <?xml version="1.0" encoding="UTF-8"?> <json:object xmlns:json="http://www.ibm.com/xmlns/prod/2009/jsonx" xsi:schemaLocation="http://www.datapower.com/schemas/json jsonx.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <json:array name="foo"> <json:string>bar</json:string> <json:boolean>true</json:boolean> <json:number>2</json:number> <json:number>3.14</json:number> <json:null/> <json:array/> <json:object/> </json:array> </json:object> */ $jsonx->fromJSONx(' <?xml version="1.0" encoding="UTF-8"?> <json:object xmlns:json="http://www.ibm.com/xmlns/prod/2009/jsonx" xsi:schemaLocation="http://www.datapower.com/schemas/json jsonx.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <json:array name="foo"> <json:string>bar</json:string> <json:boolean>true</json:boolean> <json:number>2</json:number> <json:number>3.14</json:number> <json:null/> <json:array/> <json:object/> </json:array> </json:object> '); /* object(stdClass)#180 (1) { ["foo"]=> array(7) { [0]=> string(3) "bar" [1]=> bool(true) [2]=> int(2) [3]=> float(3.14) [4]=> NULL [5]=> array(0) { } [6]=> object(stdClass)#173 (0) { } } } */
Integrations
Want to add full XML support to your JSON-speaking Laravel API with just one middleware? Check out danharper/laravel-jsonx.
Want automatic conversion of your PSR-7 compatible messages? Check out danharper/psr7-jsonx.
统计信息
- 总下载量: 55.84k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 20
- 点击次数: 1
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-11-22