PHPackages                             ronolo/json-query - 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. ronolo/json-query

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

ronolo/json-query
=================

A JSON dot.notation parser to access values. Example: persons.2.hobby

1.2.2(5y ago)1171MITPHPPHP &gt;= 7.2CI failing

Since Oct 9Pushed 5y ago2 watchersCompare

[ Source](https://github.com/RoNoLo/json-query)[ Packagist](https://packagist.org/packages/ronolo/json-query)[ Docs](https://github.com/ronolo/json-query)[ RSS](/packages/ronolo-json-query/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependencies (1)Versions (8)Used By (1)

JSON Query
==========

[](#json-query)

This library can be used to access JSON data with a document database (like MongoDB, CouchDB) like property query syntax.

It is NOT an exact Dot-Notion like approach to array structures. It (imho) needs a JSON array / object structure to work that way.

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

[](#installation)

```
composer require ronolo/json-query
```

Usage
-----

[](#usage)

```
use RoNoLo\JsonQuery;

$q = JsonQuery::fromFile('data.json'); // or ...
$q = JsonQuery::fromData(['foo' => 1, 'bar' => 2]); // or ...
$q = JsonQuery::fromJson('{"foo": "bernd", "bar": "kitty"}');

$result = $q->query('foo'); // or ...
$result = $q->query('foo.bar'); // or ...
$result = $q->query('foo.2.bar'); // or ...
$result = $q->query('foo.2.bar.0.name'); // or ...
$result = $q->query('foo.bar.name'); // etc.
```

Examples
--------

[](#examples)

Please check the PhpUnit tests, to find more examples.

```
{
  "de": "Deutschland", "en": "Germany", "es": "Alemania", "fr": "Allemagne",
  "it": "Germania", "ja": "\u30c9\u30a4\u30c4", "nl": "Duitsland",
  "altSpellings": ["DE", "Federal Republic of Germany", "Bundesrepublik Deutschland"],
  "population": 80523700,
  "latlng": [51, 9],
  "persons": [
    {
      "name": "Karl",
      "hobby": [
        {
          "type": "Cars",
          "examples": [
            {"name": "Honda"},
            {"name": "Porsche", "build": ["1962", "1976", "2010"]},
            {"name": "Mercedes"}
          ]
        },
        {
          "type": "Planes",
          "examples": [{"name": "Concorde"}, {"name": "Airbus"}, {"name": "Tupolev"}]
        },
        {
          "type": "Music",
          "examples": [{"name": "Rock"}, {"name": "Pop"}, {"name": "Funk"}]
        }
      ]
    },
    {
      "name": "Jenni",
      "hobby": [
        {
          "type": "Comics",
          "examples": [{"name": "Duffy Duck"}, {"name": "Batman"}, {"name": "Superman"}]
        },
        {
          "type": "Dancing",
          "examples": [{"name": "Walzer"}, {"name": "Shuffle"}]
        }
      ]
    }
  ]
}
```

```
use RoNoLo\JsonQuery;

$q = JsonQuery::fromFile('data.json');

$result = $q->query('population'); // 80523700
$result = $q->query('bernd'); // ValueNotFound()
$result = $q->query('persons.name'); // ["Karl", "Jenni"]
$result = $q->query('persons.1.name'); // "Jenni"
$result = $q->query('latlng'); // [51, 9]
$result = $q->query('latlng.0'); // 51
$result = $q->query('persons.hobby.type'); // [["Cars", "Planes", "Music"],["Comics","Dancing"]]
```

Limitations
-----------

[](#limitations)

Because of the nature of multidimensional arrays, queries which are very deep into the structure are possibly returned as multidimensional arrays. See PhpUnit example with 'persons.hobby.type' as the query.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity58

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

Every ~61 days

Recently: every ~85 days

Total

7

Last Release

2046d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/043b3962813e9815beff7da0bcd89ce3f380aeefcb22a721e57a287c65521636?d=identicon)[RoNoLo](/maintainers/RoNoLo)

---

Top Contributors

[![RoNoLo](https://avatars.githubusercontent.com/u/17102148?v=4)](https://github.com/RoNoLo "RoNoLo (1 commits)")

---

Tags

jsonparserdataquery

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[salsify/json-streaming-parser

A streaming parser for JSON in PHP.

7766.7M15](/packages/salsify-json-streaming-parser)[nahid/jsonq

JsonQ is a PHP based json data query library

873651.3k7](/packages/nahid-jsonq)[cerbero/json-parser

Zero-dependencies pull parser to read large JSON from any source in a memory-efficient way.

803474.6k5](/packages/cerbero-json-parser)[samayo/country-json

A simple but useful data of the world (by country) in JSON formats

1.1k22.4k](/packages/samayo-country-json)[pcrov/jsonreader

JSON Pull Parser

1451.2M5](/packages/pcrov-jsonreader)[bcncommerce/json-stream

A bundle of tools to work with JSON in PHP

642.2M3](/packages/bcncommerce-json-stream)

PHPackages © 2026

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