2017 © Pedro Peláez
 

library psr7-jsonx

JSONx is JSON encoded as XML

image

danharper/psr7-jsonx

JSONx is JSON encoded as XML

  • Monday, November 23, 2015
  • by danharper
  • Repository
  • 1 Watchers
  • 0 Stars
  • 1,176 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 88 % Grown

The README.md

JSONx for PSR-7

Latest Stable Version License, (*1)

An incoming Request object with a Content-Type: application/xml header, will be converted to a JSON Request., (*2)

An outgoing Response object with a Content-Type: application/json header with a corresponding Request object with a Accept: application/xml header, will be converted to an XML Response., (*3)

It does this using IBM's standard for representing JSON as XML: JSONx., (*4)

This library is just a small wrapper around danharper/jsonx. And, if you're using Laravel, you can get full JSONx just by dropping in a middleware with danharper/laravel-jsonx., (*5)

Notice The library changes the body of HTTP Messages, and so it needs an implementation of Psr\Http\Message\StreamInterface to work. Or, I might be missing a better way?, (*6)

There's a StreamFactoryInterface you can implement to do it, or there's two implementations: DiactorosStreamFactory (for the zend/diactoros PSR-7 implementation) and a CallableStreamFactory which you provide a function which will be given a string and you must return a stream containing it., (*7)

$jsonxAdaptor = new JSONxPSR7(new DiactorosStreamFactory);

// or instead of DiactorosStreamFactory, implement your own, or use:

$streamFactory = new CallableStreamFactory(function($body) { return MyPsr7Stream::fromString($body); });
$jsonxAdaptor = new JSONxPSR7($streamFactory);

Installation

composer require danharper/psr7-jsonx

Example

Convert Requests like so:, (*8)

$request = $jsonxAdaptor->request($request);

Convert Responses like so:, (*9)

$response = $jsonxAdaptor->response($request, $response);

The Versions

23/11 2015

dev-master

9999999-dev

JSONx is JSON encoded as XML

  Sources   Download

MIT

The Requires

 

The Development Requires

psr-7 json xml psr7 ibm jsonx

23/11 2015

v0.1.0

0.1.0.0

JSONx is JSON encoded as XML

  Sources   Download

MIT

The Requires

 

The Development Requires

psr-7 json xml psr7 ibm jsonx