Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Json Parser Laravel Package

keboola/json-parser

A PHP library from Keboola for parsing JSON into PHP data structures, with configurable options for handling JSON strings and files. Lightweight and straightforward to integrate into existing PHP projects.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Export & download features. Any roadmap item that ends in "let users get their data out" — CSV exports of nested API payloads, order/line-item reports, activity logs, audit extracts. The real work in these features is flattening: taking a nested JSON document, lifting the root object into a table of scalar columns, and turning each nested array into its own child table with a generated parent-link column. That is what this library does, and it is the part that otherwise becomes a bespoke, under-tested helper class.
  • Multi-table exports from a single document. Unlike a generic JSON→CSV converter, this emits a set of related CSVs (data.csv, data_items.csv, …). That directly supports decisions like "should the export be one wide spreadsheet or a zip of related tables?" — and it lets you ship the multi-table option cheaply to learn whether customers actually want it.
  • Integration connectors where CSV is the contract. Legacy ERP/CRM imports, accounting tools, spreadsheet-driven ops workflows, and partner SFTP drops almost always want flat CSV. This is a cheap way to satisfy the "we also need CSV" checkbox without building a converter per integration.
  • ETL / warehouse ingestion staging. Keboola's own use case — transform JSON API responses into CSV for bulk COPY/upload into Snowflake, BigQuery, or Redshift. Relevant if the roadmap includes a lightweight sync pipeline rather than a full ELT vendor.
  • Build vs. buy. This is a borrow-with-caveats decision. The honest comparison is roughly 1–2 engineer-days of building, testing, and owning a flattener (including nested-array-to-child-table logic and type inference) versus adopting an MIT utility from a single vendor. Adopt only if it saves that time and you isolate it behind an interface.
  • Prototype and de-risk. Use it to ship an export spike in a day, learn what customers actually need (column ordering? type coercion? child tables or one fat sheet?), then decide whether to keep, fork, or replace with an in-house implementation informed by real requirements.
  • Roadmap signal, not a platform bet. Treat it as a tactical dependency. It should not appear in architecture reviews as a strategic component, and it should not be the reason a feature slips.
  • Not a decision driver: JSON error messages. The package description leads with "clearer feedback when input is malformed," but PHP's native json_decode() with JSON_THROW_ON_ERROR covers that in one line. If better parse errors are your only need, do not add a dependency — that framing undersells what the library is actually for.

When to Consider This Package

Consider it when:

  • You need one-directional JSON → CSV, and you accept its flattening semantics: root object as a table, nested arrays as child tables with parent-link columns, inferred column types. The differentiator versus league/csv plus hand-rolled flattening is exactly this opinionated structure — if you don't want it, the build-vs-buy case collapses.
  • The workload is small-to-moderate and batch-oriented (report generation, nightly exports, admin-triggered downloads) — not streaming multi-hundred-MB files.
  • You can run it in a queued job, artisan command, or export service. It is file-oriented (it writes to a temp directory and returns file objects), so it belongs in the service layer, never in the request/response path.
  • Your team has no appetite to own a flattener, your license policy accepts MIT, and the feature is reversible or internal-facing.
  • You're prototyping and want to validate the UX of an export before investing in a first-party implementation.
  • You can wrap it: a single JsonToCsvExporter interface in your Laravel app that the rest of the codebase depends on, with the package as one swappable adapter. There is no service provider, facade, or config file, so this wrapping is not optional hygiene — it's how you keep the dependency from leaking into controllers and models.

Look elsewhere (or build) when:

  • Production-critical, customer-facing, SLA-bound output. Six stars, zero dependents, and a single-vendor maintenance model mean no community support, no security response process, and no guarantee of a next release. Acceptable for a batch job; not for a contractual deliverable.
  • You need control over the output schema. Exact header naming and ordering, per-field type overrides, and Excel-friendly encoding are not configurable. Leading zeros and large integers are at risk from type inference; heterogeneous arrays can explode the column count. If downstream importers depend on a specific shape, you'll be fighting the library.
  • You need more than flattening. Streaming large payloads, schema inference you control, delimiter/BOM edge cases, or round-trip CSV → JSON are out of scope — you'll be writing that logic anyway, at which point write the whole thing.
  • You're already on Laravel with simple payloads. collect($json)->map(...) plus fputcsv/league/csv handles a surprising amount of real-world data in ~30 lines you fully control. The marginal value of the dependency is small; the marginal cost is nonzero.
  • You need XLSX, not CSV. Different problem — PhpSpreadsheet or a hosted export service.
  • The JSON shape is unstable or deeply nested. You'll spend more time accommodating its tree/table rules than writing a recursive walker tailored to your domain.
  • You need non-local storage or cross-platform CI. It wants real filesystem paths and a writable temp directory; remote disks (S3) require a local staging step plus upload.

Risk note for the adoption decision: low stars and zero dependents are not disqualifying for a small utility, but they do mean you own the maintenance. It pulls Keboola's own php-temp/php-utils transitively — those are the pieces most likely to conflict with your PHP version or filesystem assumptions, so pin them in composer.lock and treat upgrades as manual review. Also budget for CSV formula injection (cells starting with =, +, -, @) if humans will open these exports in Excel. Decide up front whether you'd fork it if upstream goes quiet; if the answer is no, don't ship it in anything load-bearing.

How to Pitch It (Stakeholders)

For executives: This is a small, free, MIT-licensed utility that turns nested JSON into one or more CSV files — the tedious flattening step behind any data-export feature. It lets us ship an export capability in days rather than weeks, at zero licensing cost and with no vendor contract. It is deliberately not a strategic dependency: it's a narrow helper we will wrap behind our own interface, so replacing it later is an afternoon of work, not a migration project. The trade-off is honest: it's a six-star, single-maintainer project with no commercial support, so we should treat it as tactical and keep it off the critical path for anything contractual. Recommendation: adopt for the export feature, cap the investment, and revisit if export volume or customer commitments grow.

For engineering: Scope is a single responsibility — take a JSON document, return a set of related CSV files (root scalars as one table, each nested array as a child table with a parent-link column), with inferred column types. There's no service provider or config, so plan for ~a day of wiring: bind a singleton with a PSR-3 logger, add a config file (temp path, delimiter, enclosure), and translate the returned file objects into Storage puts — it writes real files to a temp directory, so keep it inside ShouldQueue jobs and console commands, never in the request path, and do atomic write-then-move with cleanup in a finally or terminating hook. Define App\Contracts\JsonToCsvExporter and implement it with the package as one adapter; never call the parser classes from controllers or models. Before it touches anything customer-visible: run it against three representative production payloads and capture exact CSV output as golden fixtures, agree the header-naming and child-table contract with downstream consumers, sanitize formula-injection prefixes, verify the pinned release's PHP/Laravel constraint (8.1+/Laravel 10–11) and that the transitive Keboola temp/utils packages behave in our containers, and add row-count/file-size/duration logging. If league/csv plus a hand-rolled flattener turns out comparable in effort once you've done that spike, prefer the in-house version and drop the dependency — but if the spike shows the package's tree-to-tables behavior is 80% of what we need, keep it and spend the saved days on the export UX instead.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
elmogy/larafast
xeviant/laravel-paystack
gorilladash/laravel-website-sdk
martialbe/flysystem-oss
chondal/3312client
jeroen-g/flickr
opscale-co/nova-genbi
itsjustvita/laravel-retention
tequilarapido/trackit
gregsphotography/site-builder-filament
cabaoctavio/laravel-query-log
gregsphotography/site-builder-components
io-digital/clickatell
snowsoft/laravel-admin
oxygen/auth
relicsoftware/barakah-payment-gateway
tobya/work-with-composer
equipc/laravel-email-validator
equipc/laravel-email-database-log
adedsec/nova-translated-labels