Search by

slonline / jsonfield

odraska

JSON MySQL DB Field - Module for SilverStripe 6

Package info

github.com/SLONline/jsonfield

pkg:composer/slonline/jsonfield

Statistics

Installs: 123

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

6.1.0 2026-10-09 09:36 UTC

This package is auto-updated.

Last update: 2026-10-09 10:04:41 UTC


README

Requirements

  • silverstripe/framework ~6.0

Installation

  • Add the following code to the require key in composer.json file:
composer require slonline/jsonfield

Usage

Datatype

$db = [
    ...
    'MyJSON' => DBJSONText::class,
];

AI agents (MCP)

With slonline/silverstripe-mcp installed, AI agents can read and write DBJSONText fields as JSON values (objects, lists, strings, numbers, …); null clears the field.

Describe the expected structure with a JSON Schema so the agent knows what to write. Writes that do not match the schema are rejected with the path of the first error:

private static array $mcp_json_schemas = [
    'OpeningHours' => [
        'type' => 'object',
        'description' => 'Opening hours per weekday',
        'properties' => [
            'days' => [
                'type' => 'array',
                'items' => [
                    'type' => 'object',
                    'properties' => [
                        'day' => ['type' => 'string', 'enum' => ['mon', 'tue', 'wed', 'thu', 'fri']],
                        'from' => ['type' => 'string', 'pattern' => '^\\d{2}:\\d{2}$'],
                    ],
                    'required' => ['day', 'from'],
                ],
            ],
        ],
        'required' => ['days'],
    ],
];

Without a schema any JSON value is accepted.