evals
scenario-1
scenario-10
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
Build a JSON stream processor that extracts and processes product information from a large streaming JSON dataset. The system should handle product data as it arrives without waiting for the complete dataset.
The streaming JSON data has the following structure:
{
"metadata": {
"source": "inventory-system",
"timestamp": "2025-01-15T10:00:00Z"
},
"products": [
{
"id": "P001",
"name": "Laptop",
"price": 999.99,
"category": "Electronics"
},
{
"id": "P002",
"name": "Mouse",
"price": 29.99,
"category": "Electronics"
}
]
}Implement a module that:
The solution should process data progressively as it streams in, not after the entire response arrives.
Your module should export functions or provide methods to:
The processor should gracefully handle:
@test
Input: JSON stream with root object containing metadata and products array
Expected Output: Complete root object is captured
@test
Input: JSON stream with metadata.source = "inventory-system"
Expected Output: String value "inventory-system" is extracted
@test
Input: JSON stream with 3 products in the products array
Expected Output: All 3 product objects are collected in an array
@test
Input: JSON stream with products having names "Laptop", "Mouse", "Keyboard"
Expected Output: Array containing ["Laptop", "Mouse", "Keyboard"]
@test
Input: JSON stream where first product has price 999.99
Expected Output: Number value 999.99
Main module implementing the stream processor.
Test suite validating all functionality.
Provides streaming JSON parsing and pattern matching capabilities.