[Enterprise SONiC] JSON format & /etc/sonic/config_db.json Follow
Example:
Reference model :
- Switch model name: All
- Edgecore SONiC version: All
Caution :
- Content in /etc/sonic/config_db.json can be considered as starting config (refer to this article). It follows standard JSON format
- The wrong JSON format in /etc/sonic/config_db.json may not apply the setting and/or cause the container not to work.
JSON Data Types:
JSON Strings
Strings in JSON must be written with double quotes:
"platform"
JSON Numbers
Numbers must be an integer or a floating point.
1234567890 or 0.15
JSON Objects
- JSON objects are surrounded by curly braces {}.
- JSON objects are written in key/value pairs.
- Keys must be strings, and values must be a valid JSON data type (string, number, object, array, boolean or null).
- Keys and values are separated by a colon.
- Each key/value pair is separated by a comma.
Caution: Object as values in JSON must follow the same results as JSON objects.
{"platform": "x86_64-accton_as7816_64x-r0"}
Example:
Object = {Key: Value}
Key must be strings. so, key must be written with double quotes
Value can be an object. Most of cases in SONiC (/etc/sonic/config_db.json), values are objects.
Object = {Key1: Value1, Key2: Value2}
= {Key1: {key3: value3, key4: value4}, Key2: {key5: value5}}
i.e Value1 and Value2 are objects that consist of key3/value3, key4/value4 and key5/value5
Value1 = {key3: value3, key4: value4}
Value2= {key5: value5}
JSON Arrays
Values in JSON can be arrays. Array values must be of type string, number, object, array, boolean or null.
"ports": ["Ethernet0", "Ethernet1"]
JSON Booleans
Values in JSON can be true/false.
{"disable": true}
JSON null
Values in JSON can be null
{"platform": null}
Note: JSON Whitespace (Space, Horizontal tab, Line feed or New line or Carriage return)
Whitespace outside of string literals is ignored. i.g Insignificant whitespace may be included anywhere except within JSON Numbers and JSON String. Numbers can't have whitespace inside and strings would be interpreted as whitespace in the string or cause an error.
i.e. These two examples shown below are the same.
"BGP_NEIGHBOR":{"10.0.0.1":{"asn":"65200","holdtime":"180","keepalive":"60","local_addr":"10.0.0.0","name":"ARISTA01T2","nhopself":0,"rrclient":0}}
"BGP_NEIGHBOR": {
"10.0.0.1": {
"asn": "65200",
"holdtime": "180",
"keepalive": "60",
"local_addr": "10.0.0.0",
"name": "ARISTA01T2",
"nhopself": 0,
"rrclient": 0
}
}
Comments
0 comments
Please sign in to leave a comment.