Skip to content

YAGIRO practice

Count JSON Lines records when a string contains a line break

Two stage cards contain three spoken instructions. Find the boundary between the cards and the line break inside the first prompt.

Count the physical records

Open stage-cards.jsonl with line endings visible. Its first object ends with a closing brace followed by CRLF. A second object follows, also ending in CRLF.

Read the first prompt as written in the file. The backslash and n between lift and hold encode one line-feed character inside the string. They occupy two characters in the source text and do not split the record.

Read the decoded prompt

Use the lines-to-array direction. Expect two objects in the same order, B1 then B2. The first prompt decodes to lift, one line feed, then hold. The second prompt is fold.

Compare the parsed array with stage-cards.array.json. A JSON text view will show an escape inside the first prompt. A viewer that displays decoded field values may show lift and hold on separate display lines.

Identify the rejected line

Try blank-line.jsonl. An extra CRLF between the two cards creates an empty second physical line. This reader stops at line 2. It does not skip forward to the next card.

A single terminator after the final object is accepted. To test the other permitted ending, remove only that final CRLF in a working copy of the original. It should still produce two records.

Choose a repair from evidence

If an export contains a blank line, check whether the source intended a separator or lost a record. Removing a blank line would change the physical positions used in an investigation.

General JSON Lines places one JSON value on each line. The NDJSON specification permits a documented parser option to skip empty lines. This converter uses a strict rule, so record that rule when handing a file to another reader.

Files for this exercise

Fictional JSON and JSON Lines practice data. Use the file labeled as input in the tool. The answer files describe accepted results or expected refusals; compare them with your result.

Reference sources

Continue with a check