decatur / ansatz27

⚠️ Deprecated. A validating and round-tripping JSON Parser and Stringifier for GNU Octave and MATLAB®.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Schema parsing error

YuriOsokin opened this issue · comments

Schema's type sometimes is evaluated as cell of values, and sometimes as a string. In JSON.m line 250 if the type is string 'object', ismember() function returns array and the && in the conditional statement throws an error.
The json file and the schema are attached.
ParametersSchema.txt
Parameters.txt

Hi Yuri,

currently, referenced schemas outside the normal schema structure must be under definitions.
Also, the schema under Calibration is invalid.

Right now the schema parser is not very sophisticated in validating schemas, so I will keep this ticket open.

There was issue #4, thanks.

Below is your rewritten schema which works for me.

Greetings Wolfgang

{
    "title": "KLM Schema",
    "type": "object",
    "properties": {
        "SEK": {
            "description": "SEK parameters",
            "type": "object",
            "required": [
                "Modules"
            ],
            "properties": {
                "Modules": {
                    "type": "object",
                    "required": [
                        "PF"
                    ],
                    "properties": {
                        "PF": {
                            "type": "object",
                            "oneOf": [
                                {"$ref": "#/definitions/Filter"},
                                {"$ref": "#/definitions/Calibration"}
                            ]
                        }
                    }
                }
            }
        },
        "Signals": {
            "type": "object"
        }
    },
    "required": [
        "SEK",
        "Signals"
    ],
    "definitions": {
        "Filter": {
            "type": "object",
            "required": [
                "Type",
                "Value"
            ],
            "properties": {
                "Type": {
                    "type": "string",
                    "pattern": "Filter"
                }
            }
        },
        "Calibration": {
            "type": "object",
            "required": [
                "Type",
                "Value"
            ],
            "properties": {
                "Type": {
                    "type": "string",
                    "pattern": "Calibration"
                },
                "Value": {
                    "type": "object",
                    "required": [],
                    "oneOf": [{"type":"string","pattern":"Length"},{"type":"string","pattern":"AcousticLength"}]
                }
            }
        }
    }
}