Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The public 公用的 schema describes Spread描述了 Spread.Sheets JSON data format, makes the Spread数据格式,这使 Spread.Sheets JSON data clear and useful for human and machine-readable documentation, and also provides complete structural validation which is useful for generating Spread.Sheets JSON data with code, automated testing, and validation of the JSON data. Refer to Spread Schema for the complete schema list.For more information about JSON Schema, see the 格式的数据简单易用,可读性也比较高。也提供了完整的数据验证来验证给出的 JSON 是否合理。

请查看 Spread Schema 来获取完整的 Schema 列表。

如果想了解更多有关 JSON Schema 的信息,请访问 json-schema.org web site.

The JSON Schema document can be used to check whether a JSON data is valid. You can also create a valid JSON data according to the JSON Schema.This is a basic example of a JSON Schema:文档可以被用来检查 JSON 数据是否正确。

你也可以通过 JSON Schema 来创建一个正确格式的 JSON 数据。

以下例子演示了如何使用 JSON Schema



Schema

Copy Code

{
      "title": "LineBorder",
      "description": "Indicates the color of the border line. Use a known color name or HEX style color value. The default value is black.",
      "type": "object",
      "properties": {
        "color": {
          "type": "string",
          "default": "black"
        },
        "style": {
          "$ref": "#/definitions/LineStyle",
          "default": 0
        }
      }
    }


For information about using a theme to create a validator, refer to this web site, 想了解更多创建校验器的信息,请访问:http://json-schema.org/implementations.html. This site, 

你可以在 https://json-schema-validator.herokuapp.com, has online validators you can use to check your JSON data based on the JSON Schema document.

You can use the Spread.Sheets JSON Schema document to validate the Spread.Sheets JSON data.

The following steps validate Spread.Sheets JSON data using the json 在线验证 JSON 数据是否符合 JSON Schema。


你可以使用 Spread.Sheets 中的 JSON Schema 来校验 Spread.Sheets 的 JSON 数据。

请按照以下步骤操作来使用 Spread.Sheets 中的 json-schema-validator .

...

来校验数据:

  1. 校验 JSON  数据的一部分

    比如你有两组名叫 "NameInfo" 的 JSON 数据,你想知道这两组数据哪一个是正确的数据。


    jsonData1

    Copy Code

    {
        "name":"name1",
        "row":4,
        "column":3,
        "formula":"=SUM(A1,A3)"
    }
    



    jsonData2

    Copy Code

    {
    "name":"name1",
        "row":"4",
        "column":3,
        "formula":"=SUM(A1,A3)"
    }
    


    You can get the JSON Schema document of "NameInfo" as in the following:NameInfo 的 JSON Schema 如下所示:


    NameInfo_JSONSchema

    Copy Code

    {
          "title": "NameInfo",
          "description": "Represents a custom named expression that can be used by formulas.",
          "type": "object",
          "properties": {
            "name": {
              "type": "string"
            },
            "row": {
              "type": "integer",
              "minimum": 0
            },
            "col": {
              "type": "integer",
              "minimum": 0
            },
            "formula": {
              "type": "string"
            }
          }
        }
    

    Validate the JSON data using the JSON Schema. The "jsonData2" is invalid. The type of its property "row" should be "integer".


    b. A JSON schema references another JSON schema. For example, the following JSON Schema references another JSON Schema "LineStyle"使用 JSON Schema 验证 JSON 数据,就会发现 “jsonData2” 是不正确的。“row” 的类型应该是 “integer”。


    一个 JSON schema 引用了另外一个  JSON schema。例如以下 JSON Schema 引用了 "LineStyle" 的 JSON Schema.


    LineBorder

    Copy Code

    {
        "title" : "LineBorder",
        "description" : "Indicates the color of the border line. Use a known color name or HEX style color value. The default value is black.",
        "type" : "object",
        "properties" : {
            "color" : {
                "type" : "string",
                "default" : "black"
            },
            "style" : {
                "$ref" : "#/definitions/LineStyle",
                "default" : "LineStyle.empty"
            }
        }
    }
    


    If you want to validate the JSON data of "LineBorder", use a complete "LineBorder" JSON Schema.使用 “LineBorder” 的 JSON Schema 来验证 JSON 数据 “LineBorder”,


    LineBorder_Complete

    Copy Code

     {
        "title" : "LineBorder",
        "description" : "Indicates the color of the border line. Use a known color name or HEX style color value. The default value is black.",
        "type" : "object",
        "properties" : {
            "color" : {
                "type" : "string",
                "default" : "black"
            },
            "style" : {
                "$ref" : "#/definitions/LineStyle",
                "default" : "LineStyle.empty"
            }
        },
        "definitions":{
            "LineStyle":{
               "title":"LineStyle",
               "description":"Specifies the line drawing style for the border. empty:0,thin:1,medium:2,dashed:3,dotted:4,thick:5,double:6,hair:7,mediumDashed:8,dashDot:9,mediumDashDot:10,dashDotDot:11,mediumDashDotDot:12,slantedDashDot:13.",
               "enum":[0,1,2,3,4,5,6,7,8,9,10,11,12,13]
            }
        }
    }
    


  2. Validate the full JSON data. You can use the full version JSON Schema to validate the Spread.Sheets full version JSON data.你也可以使用完整的 Spread.Sheet 的  JSON Schema 来验证 JSON 数据的整体。