Json Editor and Json Schema - hqzhang/cloudtestbed GitHub Wiki
How to describe json data use schema
This is just for Jenkins Extensible Choice Parameter plugin configuration. so that I customize the Jenkins memu.
json data map to schema
There are three large types in schema: array, object, specified (string,number,boolean ...)
A = "key":"value"
B = "key":{A}
{ A,B } => {"type":"object", "properties":{A, B } }
[ {A,B},{A,B } ] => {"type":"array","items":{ "type":"object","properties":{A, B}} }
[{ }] = {{"type":"array",
"items":{
"type":"object",
"properties":{}
}}
layout:
"type":"array",
"format":"tabs"/"table"/ "select",/"checkbox"
"type":"object",
"propertyOrder" : 1,
"format":"grid",
"options": {"layout": "grid","grid_columns":3},
#Json Editor options can be use in global and specified item theme: "bootstrap3", //CSS Integration iconlib:"fontawesome4", schema: [{}] //structure startval:[{}] //instance show_errors:"always" "options":{ theme: "bootstrap3" } #how to load Json
def jsonEditorOptions = Boon.fromJson(/{
disable_edit_json: true, //button for edit json
disable_properties: true, //button for properties
no_additional_properties: true,
disable_collapse: true, //button for collapse
disable_array_add: true, //button for add more tuple
disable_array_delete: true, //button for delete tuple
disable_array_reorder: true, //button for adjust tuple
grid_columns:3,
show_errors:"always" //for debug
theme: "bootstrap3", ////CSS Integration
iconlib:"fontawesome4",
schema: { //json schema
"title": "media fusion test",
"type": "array",
"format":"tabs",
"items": {
"headerTemplate":"{{self.channel}}",
"type": "object",
"format":"grid", "options": {"layout": "grid","grid_columns":1},
"properties":{
"channel":{ "type": "string","propertyOrder" : 1},
"confirm": { "type": "boolean" },
"entity0":{
"title":"givename",
"type": "object",
"format":"grid", "options": {"layout": "grid"},
"properties": {
"name": { "type": "string", "propertyOrder" : 1 },
"age": { "type": "integer", "propertyOrder" : 2 },
"sex": { "type": "string", "enum":[male","female"]}, "propertyOrder" : 3 },
"confirm": { "type": "boolean", "propertyOrder" : 4 },
}
}
}
}
},
startval:[ {
"channel":"myalpha",
"confirm": false,
"entity0":{
"name" :"John", "age" :26, "sex":"male","confirm":true
}
},{
"channel":"mystale",
"entity0":{
"name" :"Susan", "age" :38, "sex":"female","confirm":true
}
}]
}/);