From f9994c7ffb5f84303b7c8fc23356d9ea8d702137 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Wed, 22 Aug 2018 15:31:59 +0100 Subject: [PATCH] mltools: JSON: Implement JSON.Null. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Implements the ‘null’ value. --- common/mltools/JSON.ml | 2 ++ common/mltools/JSON.mli | 1 + 2 files changed, 3 insertions(+) diff --git a/common/mltools/JSON.ml b/common/mltools/JSON.ml index 8c2e695e2..7418f1372 100644 --- a/common/mltools/JSON.ml +++ b/common/mltools/JSON.ml @@ -20,6 +20,7 @@ type field = string * json_t and json_t = + | Null | String of string | Int of int64 | Float of float @@ -106,6 +107,7 @@ and output_list fields ~fmt ~indent = ^ (print_dict_before_end ~fmt ~indent ~size) ^ (print_indent ~fmt ~indent) ^ "]" and output_field ~indent ~fmt = function + | Null -> "null" | String s -> json_quote_string s | Int i -> Int64.to_string i (* The JSON standard permits either "1" or "1.0" but not "1.". diff --git a/common/mltools/JSON.mli b/common/mltools/JSON.mli index c85b786ff..810de6460 100644 --- a/common/mltools/JSON.mli +++ b/common/mltools/JSON.mli @@ -20,6 +20,7 @@ type field = string * json_t (** ["field": "value"] *) and json_t = (** JSON value. *) + | Null (** special null value *) | String of string (** string value, eg. ["string"] *) | Int of int64 (** int value, eg. [99] *) | Float of float (** floating point value, eg. [9.9] *)