Skip to content

schema_en

YANG Huan edited this page Sep 17, 2018 · 2 revisions

Use the "-c" parameter to generate a file that contains Excel format information. 例如使用

 python proton.py -p "sample.xlsx sample2.xlsx" -f out -e json -c Schema.json -t Conf

Export https://github.com/yanghuan/proton/tree/master/raw/en inside sample.xlsx and sample2.xlsx, will be Schema.json file, as follows

[
 {
  "root": "HerosConf", 
  "schema": {
   "Id": [
    "int", 
    "unique id of hero"
   ], 
   "Name": [
    "string", 
    "the name of hero"
   ], 
   "MountId": [
    "int", 
    "Mount"
   ], 
   "Sex": [
    "bool", 
    "the sex of hero"
   ], 
   "Height": [
    "double", 
    "the height of hero"
   ], 
   "Weapons": [
    [
     "int"
    ], 
    "The weapon used"
   ], 
   "Property": [
    {
     "Hp": [
      "int"
     ], 
     "Magic": [
      "int"
     ]
    }, 
    "The main attributes"
   ], 
   "Bags": [
    [
     {
      "Id": [
       "int"
      ], 
      "Count": [
       "int"
      ]
     }
    ], 
    "Backpack items"
   ]
  }, 
  "item": "Hero", 
  "exportfile": "out\\HerosConf.json"
 }, 
 {
  "root": "GlobalConf", 
  "schema": {
   "NameLimit": [
    "int", 
    "Name Word Limit"
   ], 
   "HitCorrection": [
    "double", 
    "Hit correction factor"
   ], 
   "LevelRange": [
    {
     "Min": [
      "int"
     ], 
     "Max": [
      "int"
     ]
    }, 
    "Level range"
   ], 
   "InitItems": [
    [
     "int"
    ], 
    "Initial acquisition of props"
   ]
  }, 
  "item": "Global", 
  "exportfile": "out\\GlobalConf.json"
 }, 
 {
  "root": "MountsConf", 
  "schema": {
   "Id": [
    "int", 
    "unique id "
   ], 
   "Name": [
    "string", 
    "the name"
   ]
  }, 
  "item": "Mount", 
  "exportfile": "out\\MountsConf.json"
 }
]

The content is an array, each of which describes the structure of a Sheet of information, which is a json object has four fields, the following specific description.

  • "item" The identity for the Sheet page

  • "root" When the header format is Format 1, the suffix information appended to the sheet is derived with the label + 's' + the parameter "-t". When the header format is Format 2, the middle character 's' is not included. This string will also be the name of the generated configuration file

  • "exportfile" The path of the exported configuration file

  • "schema" Format information, json object, each field corresponds to Excel in a field of the export information. Field name with the field name in Excel, the field value is an array, the first item of the array is the type description, the second item is the field text description information, generally used to generate comments

Read and analyze this json file, you can complete the code generation tool development, specific coding can refer to [CSharpGeneratorForProton] (https://github.com/yanghuan/CSharpGeneratorForProton).

Clone this wiki locally