JSON‐Parse Info - thepoopooman652/proishs-webtools GitHub Wiki

json-parse — JSON & NDJSON viewer

Overview

json-parse accepts JSON-formatted files (JSON arrays, objects, or newline-delimited JSON/NDJSON) and renders their data as an interactive HTML table. A pretty-printed raw JSON preview is also provided to inspect source structure.

Files

  • index.php — Upload UI and server-side parser. Handles standard JSON files, NDJSON, and simple scalar lists. Normalizes heterogeneous rows and computes a union of keys for table columns when input is an array of objects.

Normalization rules

  • Array of objects: column headers are the union of object keys across all rows; missing fields render as empty cells.
  • Array of arrays: each array becomes a row; column count equals the maximum columns found across rows.
  • NDJSON (newline-delimited JSON): each line is parsed independently; parsed entries are normalized according to the same rules as above.
  • Scalars or single objects: scalars are presented in a single-column table; single objects use their keys as headers.

Cell rendering

  • Primitive types (strings, numbers, booleans) are rendered as text with HTML escaping.
  • Nested objects/arrays are stringified (JSON-encoded) and displayed in a single cell. For advanced flattening, a transformation step must be applied to produce columnar fields.

Configuration and limits

  • Maximum file size: configured in the server-side upload checks and affected by php.ini upload settings; adjust as needed.
  • Output mode: the page shows both the tabular view and a raw pretty-printed JSON panel for debugging and verification.

Examples

  1. JSON array of objects

Input:

[
	{"id": 1, "name": "Alice"},
	{"id": 2, "email": "[email protected]"}
]

Table header: id, name, email.

  1. NDJSON

Input (lines):

{"time": "2025-01-01T00:00:00Z", "value": 42}
{"time": "2025-01-01T00:01:00Z", "value": 43}

Rendered as two rows with columns time and value.

Testing & local run

Start a local PHP server for quick verification:

cd 'C:\Users\Administrator\Documents\GitHub\proish-webtools\json-parse'
php -S 127.0.0.1:8000 -t .

Open http://127.0.0.1:8000/index.php and test with JSON arrays, objects and NDJSON streams.

Notes on extensibility

  • Flattening nested objects into additional columns requires a deterministic schema or a mapping function to convert nested keys into column names (e.g., address.cityaddress_city).
  • For very large JSON datasets consider streaming parsing and incremental rendering (pagination) rather than rendering everything in a single request.

Changelog

  • 2025-11-06: Documented normalization rules, examples, and run steps.