summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Estabrook <jestabro@vyos.io>2023-05-03 09:24:32 -0500
committerJohn Estabrook <jestabro@vyos.io>2023-05-10 22:52:25 -0500
commita86fa26041fae96c6aec7c1a306e85793f4fb021 (patch)
tree7d9445b2c92a322a07d74ccea90ae6efff83d693
parent7b40f631380164ac0e06bfec3c82ceb667f98423 (diff)
downloadvyos1x-config-a86fa26041fae96c6aec7c1a306e85793f4fb021.tar.gz
vyos1x-config-a86fa26041fae96c6aec7c1a306e85793f4fb021.zip
T5194: override json serialization for node_type variant
-rw-r--r--src/reference_tree.ml18
-rw-r--r--src/reference_tree.mli13
2 files changed, 17 insertions, 14 deletions
diff --git a/src/reference_tree.ml b/src/reference_tree.ml
index bf7f35a..84f1934 100644
--- a/src/reference_tree.ml
+++ b/src/reference_tree.ml
@@ -1,8 +1,12 @@
type node_type =
- | Leaf [@name "leaf"]
- | Tag [@name "tag"]
- | Other [@name "other"]
- [@@deriving yojson]
+ | Leaf
+ | Tag
+ | Other
+
+let node_type_to_yojson = function
+ | Leaf -> `String "leaf"
+ | Tag -> `String "tag"
+ | Other -> `String "other"
type value_constraint =
| Regex of string [@name "regex"]
@@ -13,7 +17,7 @@ type completion_help_type =
| List of string [@name "list"]
| Path of string [@name "path"]
| Script of string [@name "script"]
- [@@deriving yojson]
+ [@@deriving to_yojson]
type ref_node_data = {
node_type: node_type;
@@ -30,9 +34,9 @@ type ref_node_data = {
keep_order: bool;
hidden: bool;
secret: bool;
-} [@@deriving yojson]
+} [@@deriving to_yojson]
-type t = ref_node_data Vytree.t [@@deriving yojson]
+type t = ref_node_data Vytree.t [@@deriving to_yojson]
exception Bad_interface_definition of string
diff --git a/src/reference_tree.mli b/src/reference_tree.mli
index fcd0c32..538af91 100644
--- a/src/reference_tree.mli
+++ b/src/reference_tree.mli
@@ -1,8 +1,7 @@
type node_type =
- | Leaf [@name "leaf"]
- | Tag [@name "tag"]
- | Other [@name "other"]
- [@@deriving yojson]
+ | Leaf
+ | Tag
+ | Other
type value_constraint =
| Regex of string [@name "regex"]
@@ -13,7 +12,7 @@ type completion_help_type =
| List of string [@name "list"]
| Path of string [@name "path"]
| Script of string [@name "script"]
- [@@deriving yojson]
+ [@@deriving to_yojson]
type ref_node_data = {
node_type: node_type;
@@ -30,9 +29,9 @@ type ref_node_data = {
keep_order: bool;
hidden: bool;
secret: bool;
-} [@@deriving yojson]
+} [@@deriving to_yojson]
-type t = ref_node_data Vytree.t [@@deriving yojson]
+type t = ref_node_data Vytree.t [@@deriving to_yojson]
exception Bad_interface_definition of string