JSON field

The BPC provides a multi-line JSON editor. This field automatically validates the input and provides assistance in the event of syntax errors.

Use

To use the field, only a component with the xtype bpcJsonField must be created.

Copy&Paste example
Ext.create({
    xtype:"window",
    autoShow: true,
    title: "JSON Field",
    layout: "fit",
    width: 500,
    height: 300,
    items:[
        {
            xtype: "bpcJsonField",
            value: {
                "number": 1,
                "array":[],
                "object":{},
                "string": "I'm a JSON object"
            }
        }
    ]
});

JSON schema validation

Optionally, validation against a JSON schema (https://json-schema.org/) can also be carried out. The attribute jsonSchema must also be specified for this. The schema can be specified as a URL or transferred directly as a JSON object.

Copy&Paste example
Ext.create({
    xtype:"window",
    autoShow: true,
    title: "JSON Field",
    layout: "fit",
    width: 500,
    height: 300,
    items:[
        {
            xtype: "bpcJsonField",
            jsonSchema: {
             "type": "object",
              "required": [
                "first-name",
                "address",
                "last-name"
              ]
            },
            value: {
                "first-name":"John",
                "address" : "Foo Ave... (delete one item to get an error)",
                "last-name": "Doe"
            }
        }
    ]
});

Keywords: