PHPackages                             msqoor/json - 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. [API Development](/categories/api)
4. /
5. msqoor/json

ActiveLibrary[API Development](/categories/api)

msqoor/json
===========

This library implements the JSON API specification, refer to http://jsonapi.org/

0.0.3(10y ago)034Apache-2.0PHP

Since Jan 4Pushed 10y agoCompare

[ Source](https://github.com/msqoor/JSON-API)[ Packagist](https://packagist.org/packages/msqoor/json)[ RSS](/packages/msqoor-json/feed)WikiDiscussions stable Synced 4w ago

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

JSON API PHP Library
--------------------

[](#json-api-php-library)

This library implements the

#### TODO:

[](#todo)

- More tests

### How to use

[](#how-to-use)

```
$factory = new Json\Factory();
$documentBuilder = new Json\Document\Builder($factory);

$dataBuilder = $documentBuilder->getDataCollectionBuilder();

$documentLinksBuilder = $documentBuilder->getLinksCollectionBuilder();
$documentMetaBuilder = $documentBuilder->getMetaCollectionBuilder();
$documentIncludedBuilder = $documentBuilder->getIncludedCollectionBuilder();

// building the document data
$dataBuilder
    ->setId(1)
    ->setAttributes([
        'firstName' => 'Foo',
        'lastName' => 'Bar',
        'age' => 20,
        'active' => true
    ])
    ->setType('person');

// setting data relationships
$dataRelationshipsBuilder = $dataBuilder->getRelationshipsCollectionBuilder();
$dataRelationshipsBuilder->setName('friends');

$dataRelationshipsDataBuilder = $dataRelationshipsBuilder->getDataCollectionBuilder();
$dataRelationshipsDataBuilder
    ->setId(2)
    ->setType('person')
    ->setAttributes([
        'firstName' => 'Foo 1',
        'lastName' => 'Bar',
        'age' => 20,
        'active' => true
    ]);
$dataRelationshipsDataBuilder->addData()->addToParent(); // added data to relationships

$dataRelationshipsLinksBuilder = $dataRelationshipsBuilder->getLinksCollectionBuilder();
$dataRelationshipsLinksBuilder
    ->setName('self')
    ->setHref('http://www.facebook.com/2');
$dataRelationshipsLinksBuilder->addLink()->addToParent(); // added links to relationships

$dataRelationshipsMetaBuilder = $dataRelationshipsBuilder->getMetaCollectionBuilder();
$dataRelationshipsMetaBuilder
    ->setName('createdAt')
    ->setValue('19 July');
$dataRelationshipsMetaBuilder->addMeta()->addToParent(); // added meta to relationships

$dataRelationshipsBuilder->addRelationships()->addToParent(); // added relationships to data

$dataBuilder->addData()->addToParent(); // added to the document
// finished relationships and added to document

// building the document links
$documentLinksBuilder
    ->setName('self')
    ->setHref('http://www.facebook.com/me')
    ->addLink();
$documentLinksBuilder
    ->setName('related')
    ->setHref('http://www.facebook.com/1');
$documentLinksMetaBuilder = $documentLinksBuilder->getMetaCollectionBuilder();
$documentLinksMetaBuilder
    ->setName('self')
    ->setValue('yes')
    ->addMeta()
    ->addToParent();
$documentLinksBuilder->addLink()->addToParent(); // added links to the document
// finished building document links and added

// building the document meta
$documentMetaBuilder->setName('postsCount')->setValue(340)->addMeta();
$documentMetaBuilder->setName('friendsCount')->setValue(500)->addMeta();

$documentMetaBuilder->addToParent();
// finished document meta and added

echo $documentBuilder->getDocument()->getAsJson();
```

The above code will result the following:

```
{
	"data": [{
		"type": "person",
		"id": 1,
		"attributes": {
			"firstName": "Foo",
			"lastName": "Bar",
			"age": 20,
			"active": true
		},
		"relationships": {
			"friends": {
				"links": {
					"self": "http:\/\/www.facebook.com\/2"
				},
				"data": [{
					"type": "person",
					"id": 2,
					"attributes": {
						"firstName": "Foo 1",
						"lastName": "Bar",
						"age": 20,
						"active": true
					}
				}],
				"meta": {
					"createdAt": "19 July"
				}
			}
		}
	}],
	"meta": {
		"friendsCount": 500,
		"postsCount": 340
	},
	"links": {
		"related": {
			"href": "http:\/\/www.facebook.com\/1",
			"meta": {
				"self": "yes"
			}
		},
		"self": "http:\/\/www.facebook.com\/me"
	}
}
```

Feel free to contribute, or report any issues.

###  Health Score

24

—

LowBetter than 31% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

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

Every ~7 days

Total

3

Last Release

3816d ago

### Community

Maintainers

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

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/msqoor-json/health.svg)

```
[![Health](https://phpackages.com/badges/msqoor-json/health.svg)](https://phpackages.com/packages/msqoor-json)
```

###  Alternatives

[exsyst/swagger

A php library to manipulate Swagger specifications

35816.3M7](/packages/exsyst-swagger)[hubspot/api-client

Hubspot API client

24015.5M18](/packages/hubspot-api-client)[pocketmine/bedrock-protocol

An implementation of the Minecraft: Bedrock Edition protocol in PHP

172437.8k11](/packages/pocketmine-bedrock-protocol)[botman/driver-telegram

Telegram driver for BotMan

94452.6k6](/packages/botman-driver-telegram)

PHPackages © 2026

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