PHPackages                             baacode/json-browser - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. baacode/json-browser

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

baacode/json-browser
====================

Helper library for working with JSON data

v2.5.0(8y ago)1641ISCPHPPHP ^7.0

Since Nov 14Pushed 8y ago2 watchersCompare

[ Source](https://github.com/baacode/json-browser)[ Packagist](https://packagist.org/packages/baacode/json-browser)[ Docs](https://github.com/baacode/json-browser)[ RSS](/packages/baacode-json-browser/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (10)Dependencies (6)Versions (15)Used By (0)

JSON Browser
============

[](#json-browser)

[![Build Status](https://camo.githubusercontent.com/a9efa8b4d3a4cc90388969204b23b1f82d88a2d86e02662d09630398183ee3ab/68747470733a2f2f7472617669732d63692e6f72672f626161636f64652f6a736f6e2d62726f777365722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/baacode/json-browser)[![Coverage Status](https://camo.githubusercontent.com/59d97e4e4d2b31ad135e1b6c3448add516cffe078b5eb767e254612f5ca0ef50/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f626161636f64652f6a736f6e2d62726f777365722f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/baacode/json-browser?branch=master)[![Latest Stable Version](https://camo.githubusercontent.com/f0dad74fa3e74b4b3c36bf45ae8abefb3982c4b17bad039f1acdb9a9841ca58d/68747470733a2f2f706f7365722e707567782e6f72672f626161636f64652f6a736f6e2d62726f777365722f76657273696f6e)](https://packagist.org/packages/baacode/json-browser)[![License](https://camo.githubusercontent.com/ba697283138843f186ce309b99ed3786f096bd816e37b5227a95c68c93440874/68747470733a2f2f706f7365722e707567782e6f72672f626161636f64652f6a736f6e2d62726f777365722f6c6963656e7365)](https://packagist.org/packages/baacode/json-browser)[![Maintainability](https://camo.githubusercontent.com/3aeb690cf4674de05d199c9a960b6cbed6ae31ec37581c8f526f7b98ec344ad0/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f30363637333861623632323634346132616235352f6d61696e7461696e6162696c697479)](https://codeclimate.com/github/baacode/json-browser/maintainability)

Usage
-----

[](#usage)

```
use JsonBrowser\JsonBrowser;

// returns a new JsonBrowser, or throws an exception if the JSON syntax is invalid
$browser = new JsonBrowser();

// load document as JSON string
$browser->loadJSON($json);

// attach to existing document
$browser->attach($document);

// check for child node
$childExists = $browser->childExists('childName');

// get child node
$child = $browser->getChild('childName');
$child = $browser->childName; // dynamic __get() alias

// count child nodes
$numChildren = count($browser);
$numChildren = $browser->count();

// iterate through child nodes
foreach ($browser as $childName => $childNode) {
    // $childName is the index key of the child
    // $childNode is another JsonBrowser object (equivalent to $browser->getChild($childName))
}

// check for sibling node
$siblingExists = $child->siblingExists('siblingName');

// get sibling node
$child = $browser->getSibling('siblingName');

// get arbitrary node by path
$node = $browser->getNodeAt('#/childName/grandchildName/4');

// get arbitrary node value by path
$value = $browser->getValueAt('#/childName/grandchildName/4');

// set arbitrary node value by path
$browser->setValueAt('#/childName/grandchildName/4', 'myValue')

// delete arbitrary node value by path
$browser->deleteValueAt('#/childName/grandchildName/4')

// get root node
$root = $node->getRoot();

// test whether a node is the root
$nodeIsRoot = $node->isRoot();

// get parent node
$parent = $node->getParent();

// get node value
$value = $node->getValue();
$value = $parent->node; // __get() alias method when OPT_GET_VALUE is set

// set node value
$node->setValue('myValue');
$parent->node = 'myValue'; // __set() alias method

// delete node value
$node->deleteValue();

// get node type
$type = $node->getType();

// check whether the node exists
$nodeExists = $node->nodeExists();

// test whether the node is at least one of the given types
$isType = $node->isType(JsonBrowser::TYPE_STRING | JsonBrowser::TYPE_NUMBER);

// test whether the node is *not* any of the given types
$isNotType = $node->isNotType(JsonBrowser::TYPE_NULL | JsonBrowser::TYPE_INTEGER);

// test for equality
$isEqual = $node->isEqualTo("myValue");

// get node path
$path = $node->getPath();

// get JSON source for node
$json = $node->getJSON();

// get a node as the root of a subtree
$root = $node->asRoot();

// set named annotation on a node
$node->setAnnotation('myAnnotation', 'myValue'); // append to existing values
$node->setAnnotation('myOtherAnnotation', 'myOtherValue', true); // overwrite previous values

// get latest value for a named annotation, or null if not set
$annotation = $node->getAnnotation('myAnnotation');

// get array of values for a named annotation, empty array if not set
$annotations = $node->getAnnotations('myAnnotation');

// get an associative array of all annotations on a node, empty array if none set
$annotations = $node->getAnnotations();
```

Configuration Options
---------------------

[](#configuration-options)

NameDescriptionOPT\_DEFAULTUse the default options set (no user-configurable options enabled)OPT\_NONEXISTENT\_EXCEPTIONSThrow an exception when attempting to read a nonexistent valueOPT\_GET\_VALUEGet values, rather than node objects, when using `__get()`OPT\_DECODEDecode the document passed to the constructor as a JSON stringDocumentation
-------------

[](#documentation)

Comprehensive API documentation is available [here](https://baacode.github.io/json-browser/).

Installation
------------

[](#installation)

To install via composer, use:

```
$ composer require baacode/json-browser
```

Requirements
------------

[](#requirements)

- PHP &gt;= 7.0
- PHP's native JSON extension
- PHP's native mbstring extension
- seld/jsonlint &gt;= 1.0

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity66

Established project with proven stability

 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

Every ~8 days

Total

14

Last Release

2998d ago

Major Versions

v1.5.0 → v2.0.02018-01-20

### Community

Maintainers

![](https://www.gravatar.com/avatar/7fb46d21453ece06107103c9141299c7189ecea7e73b3a9e3d75950ffc75f3e2?d=identicon)[Erayd](/maintainers/Erayd)

---

Top Contributors

[![erayd](https://avatars.githubusercontent.com/u/121486?v=4)](https://github.com/erayd "erayd (127 commits)")

---

Tags

jsonjsonbrowserhelper

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

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

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

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M687](/packages/barryvdh-laravel-ide-helper)[nette/utils

🛠 Nette Utils: lightweight utilities for string &amp; array manipulation, image handling, safe JSON encoding/decoding, validation, slug or strong password generating etc.

2.1k394.3M1.5k](/packages/nette-utils)[jenssegers/agent

Desktop/mobile user agent parser with support for Laravel, based on Mobiledetect

4.8k67.8M440](/packages/jenssegers-agent)[cuyz/valinor

Dependency free PHP library that helps to map any input into a strongly-typed structure.

1.5k9.2M108](/packages/cuyz-valinor)[beste/json

A simple JSON helper to decode and encode JSON

4222.7M3](/packages/beste-json)[chillerlan/php-settings-container

A container class for immutable settings objects. Not a DI container.

3427.3M21](/packages/chillerlan-php-settings-container)

PHPackages © 2026

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