File tree 1 file changed +39
-0
lines changed
1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -12,10 +12,49 @@ namespace swss {
12
12
class JSon
13
13
{
14
14
private:
15
+ /*
16
+ * el_count represents the number of elements in each object,
17
+ * which means each object have exactly 2 elements: the data and the operator
18
+ */
15
19
static const int el_count = 2 ;
16
20
public:
17
21
static std::string buildJson (const std::vector<FieldValueTuple> &fv);
18
22
static void readJson (const std::string &json, std::vector<FieldValueTuple> &fv);
23
+ /*
24
+ bool loadJsonFromFile(std::ifstream &fs, std::vector<KeyOpFieldsValuesTuple> &db_items);
25
+
26
+ parse the json file and construct a vector of KeyOpFieldsValuesTuple as the result
27
+ the json file should be a list objects with each consisting of a data field and an operator field
28
+ - the data should be a dictionary
29
+ - the operator field should be a string, "SET" or "DEL"
30
+ an example:
31
+ [
32
+ {
33
+ "QOS_TABLE:TC_TO_QUEUE_MAP_TABLE:AZURE": {
34
+ "5": "1",
35
+ "6": "1"
36
+ },
37
+ "OP": "SET"
38
+ },
39
+ {
40
+ "QOS_TABLE:DSCP_TO_TC_MAP_TABLE:AZURE": {
41
+ "7":"5",
42
+ "6":"5",
43
+ "3":"3",
44
+ "8":"7",
45
+ "9":"8"
46
+ },
47
+ "OP": "SET"
48
+ }
49
+ ]
50
+
51
+ parameters:
52
+ fs: the input ifstream representing the json file
53
+ fv: the output vector
54
+ return: boolean
55
+ True: the input json file has been succefully parsed
56
+ False: there are some errors found
57
+ */
19
58
static bool loadJsonFromFile (std::ifstream &fs, std::vector<KeyOpFieldsValuesTuple> &db_items);
20
59
};
21
60
You can’t perform that action at this time.
0 commit comments