PHPackages                             danharper/psr7-jsonx - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. danharper/psr7-jsonx

ActiveLibrary[HTTP &amp; Networking](/categories/http)

danharper/psr7-jsonx
====================

JSONx is JSON encoded as XML

v0.1.0(10y ago)01.2kMITPHP

Since Nov 22Pushed 10y ago1 watchersCompare

[ Source](https://github.com/danharper/JSONx-for-PSR7)[ Packagist](https://packagist.org/packages/danharper/psr7-jsonx)[ RSS](/packages/danharper-psr7-jsonx/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (5)Versions (2)Used By (0)

JSONx for PSR-7
===============

[](#jsonx-for-psr-7)

[![](https://camo.githubusercontent.com/c095d652290e36393205d539dcb6af0f3438aa58d63f4d858cc6056b0df0c9ad/68747470733a2f2f6170692e7472617669732d63692e6f72672f64616e6861727065722f4a534f4e782d666f722d505352372e737667)](https://travis-ci.org/danharper/JSONx-for-PSR7) [![Latest Stable Version](https://camo.githubusercontent.com/85305bdd7e7cdad3f9bf871177af7f244b3ae835122dddd0d1c6a533de1edbda/68747470733a2f2f706f7365722e707567782e6f72672f64616e6861727065722f707372372d6a736f6e782f762f737461626c65)](https://packagist.org/packages/danharper/psr7-jsonx) [![License](https://camo.githubusercontent.com/570e79a49bee01bcd424f1b6ed2982635ee6bccd078d6b13e5a1d74087cbb30f/68747470733a2f2f706f7365722e707567782e6f72672f64616e6861727065722f707372372d6a736f6e782f6c6963656e7365)](https://packagist.org/packages/danharper/psr7-jsonx)

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

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.

It does this using IBM's standard for representing JSON as XML: [JSONx](https://tools.ietf.org/html/draft-rsalz-jsonx-00).

This library is just a small wrapper around [`danharper/jsonx`](https://github.com/danharper/jsonx). And, if you're using Laravel, you can get full JSONx just by dropping in a middleware with [`danharper/laravel-jsonx`](https://github.com/danharper/LaravelJSONx).

> **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?

There's a `StreamFactoryInterface` you can implement to do it, or there's two implementations: `DiactorosStreamFactory` (for the [`zend/diactoros`](https://github.com/zendframework/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.

```
$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
------------

[](#installation)

```
composer require danharper/psr7-jsonx

```

Example
-------

[](#example)

Convert Requests like so:

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

Convert Responses like so:

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

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

3821d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f85b25e3772649f8b096057162897f1052385f956e170e9cdf628c4ef72edede?d=identicon)[danharper](/maintainers/danharper)

---

Top Contributors

[![danharper](https://avatars.githubusercontent.com/u/510740?v=4)](https://github.com/danharper "danharper (5 commits)")

---

Tags

psr-7jsonxmlpsr7ibmjsonx

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/danharper-psr7-jsonx/health.svg)

```
[![Health](https://phpackages.com/badges/danharper-psr7-jsonx/health.svg)](https://phpackages.com/packages/danharper-psr7-jsonx)
```

###  Alternatives

[league/route

Fast routing and dispatch component including PSR-15 middleware, built on top of FastRoute.

6633.1M116](/packages/league-route)[dflydev/fig-cookies

Cookies for PSR-7 HTTP Message Interface.

2268.5M102](/packages/dflydev-fig-cookies)[violet/streaming-json-encoder

Library for iteratively encoding large JSON documents piece by piece

3162.1M5](/packages/violet-streaming-json-encoder)[neomerx/cors-psr7

Framework agnostic (PSR-7) CORS implementation (www.w3.org/TR/cors/)

682.4M19](/packages/neomerx-cors-psr7)[jimtools/jwt-auth

PSR-15 JWT Authentication middleware, A replacement for tuupola/slim-jwt-auth

20142.3k3](/packages/jimtools-jwt-auth)[danharper/laravel-jsonx

Add XML support to a JSON-speaking Laravel API with a single middleware via JSONx

1857.2k](/packages/danharper-laravel-jsonx)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
