From a86fa26041fae96c6aec7c1a306e85793f4fb021 Mon Sep 17 00:00:00 2001 From: John Estabrook Date: Wed, 3 May 2023 09:24:32 -0500 Subject: T5194: override json serialization for node_type variant --- src/reference_tree.ml | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'src/reference_tree.ml') 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 -- cgit v1.2.3