PHPackages                             biohzrdmx/jason-php - 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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. biohzrdmx/jason-php

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

biohzrdmx/jason-php
===================

A convenient wrapper for JSON documents

1.0.0(1y ago)05MITPHPPHP &gt;=8.1

Since Oct 24Pushed 1y ago1 watchersCompare

[ Source](https://github.com/biohzrdmx/jason-php)[ Packagist](https://packagist.org/packages/biohzrdmx/jason-php)[ RSS](/packages/biohzrdmx-jason-php/feed)WikiDiscussions master Synced today

READMEChangelog (1)DependenciesVersions (2)Used By (0)

jason-php
=========

[](#jason-php)

A convenient wrapper for JSON documents

Simple to use wrapper to make it even easier to work with JSON documents, loading, saving, accessing and manipulating them.

### Basic usage

[](#basic-usage)

First require `biohzrdmx/jason-php` with Composer.

There are four factory methods to create a `Document` instance from various sources:

- `fromArray` - From an array
- `fromString` - From a JSON-encoded string
- `fromFile` - From a JSON-encoded file
- `fromStream` - From a JSON-encoded stream

```
$document = Document::fromFile('/home/your-user/credentials.json');
```

Also you may use the default `constructor` which takes either an `array` or a `string`.

```
$payload = [
    'status' => 'accepted',
    'id' => '1234567890',
];
$document = new Document($payload);
```

There are also four output methods to convert the `Document`:

- `toArray` - To an array
- `toString` - To a JSON-encoded string
- `toFile` - To a JSON-encoded file
- `toStream` - To a JSON-encoded stream

```
$document->toStream($stream_handle);
```

#### Manipulation

[](#manipulation)

To access a `Document` contents you can use the `get` method, which uses *dot notation* to give you an easy to use interface:

```
{
    "order": {
        "id": 1234567890,
        "status": "pending",
        "invoice": null,
        "customer": {
            "name": "Bobby Tables"
        },
        "metadata": []
    }
}
```

```
$customer_name = $document->get('order.customer.name');
```

You can specify a default value in case the item doesn't exist:

```
$customer_type = $document->get('order.customer.type', 'guest');
```

It also includes a handy `has` method to check for the existence of some value:

```
if ( $document->has('metadata.processor') ) {
    // Do something
}
```

And you may also build your `Document` from the ground up with the `set` method:

```
$document = new Document();
$document->set('order' => ['id': 1234567890]);
$document->set('order.status' => 'pending');
$document->set('order.customer' => ['name' => 'Bobby Tables']);
$document->toString(true);
```

```
{
    "order": {
        "id": 1234567890,
        "status": "pending",
        "customer": {
            "name": "Bobby Tables"
        }
    }
}
```

### Licensing

[](#licensing)

This software is released under the MIT license.

Copyright © 2024 biohzrdmx

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

### Credits

[](#credits)

**Lead coder:** biohzrdmx &lt;[github.com/biohzrdmx](http://github.com/biohzrdmx)&gt;

###  Health Score

25

—

LowBetter than 35% of packages

Maintenance34

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity48

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

617d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/44b968bb45d47a621ce8e81c422ef4c126316a702156a7faf96df75610cc0d45?d=identicon)[biohzrdmx](/maintainers/biohzrdmx)

---

Top Contributors

[![biohzrdmx](https://avatars.githubusercontent.com/u/2053303?v=4)](https://github.com/biohzrdmx "biohzrdmx (2 commits)")

---

Tags

jsonphp

### Embed Badge

![Health badge](/badges/biohzrdmx-jason-php/health.svg)

```
[![Health](https://phpackages.com/badges/biohzrdmx-jason-php/health.svg)](https://phpackages.com/packages/biohzrdmx-jason-php)
```

###  Alternatives

[mck89/peast

Peast is PHP library that generates AST for JavaScript code

19139.2M47](/packages/mck89-peast)[sauladam/shipment-tracker

Parses tracking information for several carriers, like UPS, USPS, DHL and GLS by simply scraping the data. No need for any kind of API access.

9843.5k](/packages/sauladam-shipment-tracker)[jstewmc/rtf

Read and write Rich Text Format (RTF) documents with PHP

45153.1k6](/packages/jstewmc-rtf)[tcds-io/php-jackson

A lightweight, flexible object serializer for PHP, inspired by FasterXML/jackson

113.2k10](/packages/tcds-io-php-jackson)

PHPackages © 2026

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