PHPackages                             keboola/json-parser - 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. [PDF &amp; Document Generation](/categories/documents)
4. /
5. keboola/json-parser

ActiveLibrary[PDF &amp; Document Generation](/categories/documents)

keboola/json-parser
===================

Keboola JSON to CSV parser

4.0.0(1y ago)610.2k↓37.5%6[1 issues](https://github.com/keboola/php-jsonparser/issues)[1 PRs](https://github.com/keboola/php-jsonparser/pulls)3MITPHPPHP ^8.1CI failing

Since Oct 4Pushed 1y ago17 watchersCompare

[ Source](https://github.com/keboola/php-jsonparser)[ Packagist](https://packagist.org/packages/keboola/json-parser)[ RSS](/packages/keboola-json-parser/feed)WikiDiscussions master Synced today

READMEChangelog (8)Dependencies (8)Versions (52)Used By (3)

JSON Parser
===========

[](#json-parser)

Description
-----------

[](#description)

Parses JSON strings into CSV files. Creates multiple tables from a single JSON. Uses Keboola\\CsvFile for results. The root of the JSON must be an array. JSON parser is part of [Generic Extractor](https://github.com/keboola/generic-extractor/)(see also end-user [documentation](https://developers.keboola.com/extend/generic-extractor/)).

Usage
-----

[](#usage)

```
use Keboola\Json\Parser;
$parser = new Parser(new Analyzer(new NullLogger(), new Structure()));
$file = file_get_contents("some/data.json");
$json = json_decode($file);

$parser->process($json);

$results = $parser->getCsvFiles(); // array of CsvFile objects
```

\\Keboola\\Json\\Analyzer
=========================

[](#keboolajsonanalyzer)

Analyzes JSON data for JSON parser.

\_\_construct(\\Psr\\Log\\LoggerInterface $logger, \\Keboola\\Json\\Structure $structure, $nestedArraysAsJson, $strict)
-----------------------------------------------------------------------------------------------------------------------

[](#__constructpsrlogloggerinterface-logger-keboolajsonstructure-structure-nestedarraysasjson-strict)

- $logger - a logger, use `NullLogger` if no logger is used.
- $structure - a representation of JSON structure .
- $nestedArraysAsJson - if true, then nested arrays will be encoded as JSON strings. If false (default), the conversion will fail.
- $strict - if true, then JSON node data types will be checked more strictly (int, string, ...).

\\Keboola\\Json\\Parser
=======================

[](#keboolajsonparser)

Parses JSON data into CSV files.

\_\_construct($analyzer, $definitions = \[\])
---------------------------------------------

[](#__constructanalyzer-definitions--)

- $definitions - optional array with results from previous process.
- $analyzer - instance of analyzer class.

process($data, $type, $parentId)
--------------------------------

[](#processdata-type-parentid)

- $data - array of objects retrieved from JSON data.
- $type - is used for naming the resulting table(s).
- $parentId - either a string, which will be saved in a JSON\_parentId column, or an array with "column\_name" =&gt; "value", which will name the column(s) by array key provided.
- If the data is analyzed, it is stored in Cache and **NOT PARSED** until the `getCsvFiles()`method is called.

getCsvFiles()
-------------

[](#getcsvfiles)

- returns a list of \\Keboola\\CsvTable\\Table objects with parse results

Parse characteristics
=====================

[](#parse-characteristics)

The analyze function loops through each row of an array (generally an array of results) and passes the row into `analyzeRow()` method. If the row only contains a scalar, it's stored in a "data" column. If the row is an object, each of the object's variables will be used as a column name, and its values are analyzed:

- if it is a scalar, it'll be saved as a value of that column.
- if it is an array, it'll be passed to `analyze()` to create a new table, linked by a generated `JSON_parentId` column
- if it is another object, it'll be parsed recursively to `analyzeRow()`, with its variable names prepended by current objects' name, e.g.:

```
"parent": {
    "child" : "value1"
}

```

will result in a `parent_child` column with a string type of "value1".

###  Health Score

46

—

FairBetter than 92% of packages

Maintenance29

Infrequent updates — may be unmaintained

Popularity31

Limited adoption so far

Community24

Small or concentrated contributor base

Maturity85

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 88% 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 ~73 days

Recently: every ~629 days

Total

50

Last Release

703d ago

Major Versions

0.2.4 → 1.0.02015-09-27

1.1.0 → 2.0.02017-09-07

2.1.0 → 3.0.02021-01-14

3.0.0 → 4.0.02024-07-30

PHP version history (4 changes)0.1.14PHP &gt;=5.4.0

2.0.0PHP &gt;=7.1

3.0.0PHP &gt;=7.4

4.0.0PHP ^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/101dbf2551a0709ddab522f97669f13a2c4cc2d0a1e8d009f3af6ba80accb1a9?d=identicon)[Keboola](/maintainers/Keboola)

---

Top Contributors

[![odinuv](https://avatars.githubusercontent.com/u/4319320?v=4)](https://github.com/odinuv "odinuv (73 commits)")[![michaljurecko](https://avatars.githubusercontent.com/u/19371734?v=4)](https://github.com/michaljurecko "michaljurecko (4 commits)")[![MiroCillik](https://avatars.githubusercontent.com/u/1488015?v=4)](https://github.com/MiroCillik "MiroCillik (3 commits)")[![kachnitel](https://avatars.githubusercontent.com/u/4067705?v=4)](https://github.com/kachnitel "kachnitel (2 commits)")[![sykora-ji](https://avatars.githubusercontent.com/u/29491790?v=4)](https://github.com/sykora-ji "sykora-ji (1 commits)")

---

Tags

jsonparsercsvconverterjson2csv

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[faisalman/simple-excel-php

Easily parse / convert / write between Microsoft Excel XML / CSV / TSV / HTML / JSON / etc formats

578610.1k1](/packages/faisalman-simple-excel-php)[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.7k38.9k](/packages/matomo-matomo)[mledoze/countries

List of world countries in JSON, CSV, XML and YAML

6.2k733.8k6](/packages/mledoze-countries)[rodenastyle/stream-parser

PHP Multiformat Streaming Parser

447204.3k2](/packages/rodenastyle-stream-parser)[kartik-v/yii2-export

A library to export server/db data in various formats (e.g. excel, html, pdf, csv etc.)

1693.3M36](/packages/kartik-v-yii2-export)[ozdemirburak/json-csv

JSON to CSV and CSV to JSON converters in PHP.

40170.3k1](/packages/ozdemirburak-json-csv)

PHPackages © 2026

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