Find a Failed Record in a Batch JSON Import

Use parser diagnostics, tree output, and a path query to isolate a broken batch element while keeping automated repair under human review.

By DevSphere Editorial · · 5 min read

Open JSON Parser

Diagnose syntax before meaning

A batch import may fail before its application-level checks ever see the records. The JSON Parser helps distinguish syntax failure from a field-value problem by parsing the input live and displaying a parser error when the document is malformed. It can format, minify, sort keys, query a simple path, and transform valid JSON into several output forms. It is not a batch-import simulator and cannot determine whether a record meets the destination's business rules. In this tutorial, a fictional inventory batch has an accidental trailing comma after the last member of the second object. The goal is to find and correct only that syntax defect, then verify a known record value. Use invented SKUs and values; do not paste confidential supplier files into a browser utility without approval. Preserve the source copy separately if the import failure needs an audit trail.

[
  {"sku": "BOX-4", "quantity": 3},
  {"sku": "TAPE-2", "quantity": 6,}
]

Read the diagnostic carefully

Open JSON Parser and paste the batch into the JSON Input editor. The output pane should say Fix JSON errors to see the output, and the error area should include a browser JSON.parse message. The parser attempts to extract a numeric position from that message and may display a line number. Treat that line as a clue, not a precise token highlight: browser error wording varies, and the component does not draw a character-level caret. Here the last object's trailing comma is illegal JSON. Remove only that comma, retain the closing brace and array bracket, and confirm the status changes to Valid JSON. If the editor contains copied log text around the array, remove the surrounding text too; a JSON document must be a single valid value. Inspect punctuation from the failure location in both directions. A missing comma earlier can make the parser report a later position, so don't assume the first suspicious character is always the root cause.

Use tree and path query to verify the repair

With the corrected batch valid, leave Output Format on Tree View and expand the array if needed. Confirm there are two objects and that each has a sku and quantity member. Enter items using the actual top-level array index syntax, such as [1].sku, in Path Query; the tool's example format is users[0].name, so adapt it to this root array. The implementation normalizes numeric brackets to dot-separated properties and performs ordinary property access, which supports simple paths but not filters, quoted key expressions, or full JSONPath operators. Expect [1].sku to return TAPE-2 and [1].quantity to return 6. A valid path result confirms the repaired document's parsed value at that location; it does not verify quantity is acceptable for the receiving system. For a nested batch, query one representative field per record and inspect the whole tree when record structure varies.

[
  {"sku": "BOX-4", "quantity": 3},
  {"sku": "TAPE-2", "quantity": 6}
]

Handle Try Fix with caution

Try Fix is intentionally a best-effort convenience, not a safe refactoring engine. Its implementation changes single quotes to double quotes, adds quotes to word-like keys, removes trailing commas before brackets, and replaces undefined with null, then accepts the result only if JSON.parse succeeds. Global replacements can corrupt legitimate string contents, and undefined-to-null alters semantics. For this example the manual one-character repair is clearer and safer. If you test Try Fix on a disposable fictional sample, compare every changed character to the original and never blindly import the output. When the error persists, inspect escaped quotes, brace pairing, literal spelling, and commas one edit at a time. JSON does not allow comments, single-quoted strings, unquoted property names, or trailing commas. A parser fix can restore syntax while leaving malformed business data untouched.

Check output settings and limits

After repair, select Formatted JSON and choose an indent size if readability helps; Sort Keys can make object ordering consistent for a comparison, but sorting recursively changes the serialized presentation. Minified output removes spacing. Other output formats include escaped string, query string, CSV, YAML, XML, and TypeScript interface. Those conversions have simplified mapping rules: arrays and nested values may be flattened, quoted, or represented in a way that cannot round-trip every JSON distinction. Empty arrays, mixed record shapes, special keys, and nulls deserve particular caution. Do not use a generated interface as a complete schema or use the query string as a canonical encoding of nested values. For a repair task, keep Output Format set to Tree View and avoid converting until syntax and field locations are confirmed. If a downstream step needs another format, validate that result independently.

Verify the import-ready artifact

Before copying anything, check Valid JSON, two array members, BOX-4 quantity 3, and TAPE-2 quantity 6. Confirm the top-level value is an array rather than an object containing an array; the type summary reports the parsed value's type and size. Use Copy for the selected output, or Format to write indented JSON into the input, then preserve the final content outside the tool using your approved workflow. The parser has no knowledge of the importer, required SKU uniqueness, units, or maximum quantity. If the import still fails despite valid syntax, compare the destination schema and its error report rather than continuing to alter punctuation. A repeatable unit test for this exact input would catch future regressions. Clear resets the editor and path query when beginning a separate file. Treat this tool as a syntax and inspection aid, then rely on the importer or a schema validator for acceptance.

Browse all tutorials