UNPKG

@blade47/semantic-test

Version:

A composable, pipeline-based testing framework for AI systems and APIs with semantic validation

34 lines (29 loc) 584 B
import { Block } from '../../src/core/Block.js'; /** * JsonParser - Parses JSON strings */ export class JsonParser extends Block { static get inputs() { return { required: ['body'], optional: [] }; } static get outputs() { return { produces: ['parsed', 'error', 'raw'] }; } process(inputs, _context) { const { body } = inputs; try { const parsed = JSON.parse(body); return { parsed }; } catch (error) { return { error: `JSON parse error: ${error.message}`, raw: body }; } } }