# xAPI Export: JSON Lines (.jsonl / .txt) This document describes the format and structure used for exporting xAPI statements as **JSON Lines (JSONL)** β€” a newline-delimited JSON format that is ideal for large-scale analytics and processing. ## πŸ“„ What is JSON Lines? JSON Lines (also known as `.jsonl` or `.ndjson`) is a format where: - Each line in the file is a valid JSON object. - There is no outer array or root object. - Files can be read incrementally, one JSON object at a time. ## πŸ“¦ xAPI JSONL Export Each line in the exported file corresponds to **one full xAPI statement**, encoded as a JSON object. All properties from the xAPI specification are preserved, including nested structures such as `actor`, `object`, `context`, and `result`. ### Example Output ```json {"id":"550e8400-e29b-41d4-a716-446655440000","timestamp":"2025-06-08T12:00:00Z","actor":{"name":"Alice","mbox":"mailto:alice@example.com"},"verb":{"id":"http://adlnet.gov/expapi/verbs/answered"},"object":{"id":"http://example.com/question/1"}} {"id":"550e8400-e29b-41d4-a716-446655440001","timestamp":"2025-06-08T12:00:01Z","actor":{"name":"Bob","mbox":"mailto:bob@example.com"},"verb":{"id":"http://adlnet.gov/expapi/verbs/viewed"},"object":{"id":"http://example.com/video/1"}} ``` ## βœ… Benefits of JSONL - **Streaming-friendly**: Ideal for large datasets and incremental processing. - **Line-by-line parsing**: Supports efficient line-by-line ingestion in Python (`pandas`, `jsonlines`), Spark, and BigQuery. - **Schema-flexible**: New fields in future statements won’t break the format. ## πŸ›  Best Practices - Always use UTF-8 encoding. - End each line with `\n` (not a comma). - Avoid nested arrays unless explicitly needed β€” they complicate streaming. ## πŸ” Comparison with CSV | Feature | CSV | JSONL | |---------------|------------------|---------------------| | Human-readable| βœ… | βœ… (less readable) | | Schema-fixed | βœ… | ❌ | | Nested support| ❌ (flattened) | βœ… (native JSON) | | Parse speed | Fast | Streaming-capable | | Ideal for ML | ⚠️ (preprocess) | βœ… | ## πŸ“‚ Recommended File Extension - `.jsonl` - `.ndjson` - `.txt` (if required for legacy systems) --- Β© 2025 OmiLAXR Β· Exporting xAPI statements for high-volume analytics and machine learning workflows