使用JSON模式通过.json文件

时间:2017-04-10 11:25:38

标签: json enums jsonschema

我目前正在尝试编写一个JSON Schema来验证.json文件格式的目录。

它包含有关程序集的某些可能组件的信息,然后包含实际程序集的几个条目,其中包含引用这些组件的字符串(通过.json中的键)文件。

.json文件看起来像这样:

{
    "sensors" : {
            "sensor_type_temperature_1" : { ... info about first temperature sensor ... },
            "sensor_type_tempearature_2" : { ... info about second temperature sensor ... },
            "sensor_type_humidity_1" : { ... info about first humidity sensor ... }, ...
        }, ...
    "masts" : {
            "mast_type_1" : { ... info about first mast type ... },
            "mast_type_2" : { ... info about second mast type ... }, ...
        }, ...
    "observation_stations" : {
            "first_station" : {
                    "sensors" : ["sensor_id_tempearature_2", "sensor_id_humidity_1"],
                    "mast" : "mast_type_2",
                    "location" : { ... location ...}, ...
            "second_station" : {
                    "sensors" : ["sensor_id_tempearature_1"],
                    "mast" : "mast_type_1",
                    "location" : { ... location ...}, ...
                }
        }
}

我现在要做的是使用JSON Schema来验证我的文件。我对数据格式很好,我熟悉使用枚举来限制例如数据的实际内容。 "桅杆"的内容或"传感器"。

如何使用该方案验证传感器中的所有条目"和#34;桅杆"在观察站也是“传感器”的关键。和"桅杆"同一个.json文件的一部分?

0 个答案:

没有答案