[Pkg-ocaml-maint-commits] [yojson] 01/05: Imported Upstream version 1.3.0

Stéphane Glondu glondu at moszumanska.debian.org
Wed Jan 27 16:43:04 UTC 2016


This is an automated email from the git hooks/post-receive script.

glondu pushed a commit to branch master
in repository yojson.

commit 4d7c878e590f0e8ed5e5e9fdc8e582d217873a91
Author: Stephane Glondu <steph at glondu.net>
Date:   Wed Jan 27 17:35:27 2016 +0100

    Imported Upstream version 1.3.0
---
 Makefile |  2 +-
 read.mli |  7 +++++++
 read.mll |  2 ++
 util.ml  | 13 ++++++++++---
 util.mli | 12 +++++++++---
 5 files changed, 29 insertions(+), 7 deletions(-)

diff --git a/Makefile b/Makefile
index d7472f4..858787d 100755
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-VERSION = 1.2.3
+VERSION = 1.3.0
 
 ifeq "$(shell ocamlfind ocamlc -config |grep os_type)" "os_type: Win32"
 EXE=.exe
diff --git a/read.mli b/read.mli
index 182f587..30ad780 100644
--- a/read.mli
+++ b/read.mli
@@ -250,5 +250,12 @@ val read_json : lexer_state -> Lexing.lexbuf -> json
 val skip_json : lexer_state -> Lexing.lexbuf -> unit
 val buffer_json : lexer_state -> Lexing.lexbuf -> unit
 
+val validate_json : 'path -> json -> 'error option
+  (* always returns [None].
+     Provided so that atdgen users can write:
+
+       type json <ocaml module="Yojson.Safe"> = abstract
+  *)
+
 (* end undocumented section *)
 (**/**)
diff --git a/read.mll b/read.mll
index 6a7f129..ea9edc0 100644
--- a/read.mll
+++ b/read.mll
@@ -1209,4 +1209,6 @@ and junk = parse
 
   let compact ?std s =
     to_string (from_string s)
+
+  let validate_json _path _value = None
 }
diff --git a/util.ml b/util.ml
index 943ba69..8cf0acd 100644
--- a/util.ml
+++ b/util.ml
@@ -13,7 +13,7 @@ let typerr msg js = raise (Type_error (msg ^ typeof js, js))
 
 exception Undefined of string * json
 
-let ( |> ) x f = f x
+let ( |> ) = ( |> )
 
 let assoc name obj =
   try List.assoc name obj
@@ -192,5 +192,12 @@ let filter_string l =
   ) l
 
 let keys o =
-  let names = to_assoc o in
-  List.map (fun (key, _) -> key) names
+  to_assoc o |> List.map (fun (key, _) -> key)
+
+let values o =
+  to_assoc o |> List.map (fun (_, value) -> value)
+
+let combine (first : json) (second : json) =
+  match (first, second) with
+  | (`Assoc a, `Assoc b) -> (`Assoc (a @ b) :  json)
+  | (a, b) -> raise (Invalid_argument "Expected two objects, check inputs")
diff --git a/util.mli b/util.mli
index aa777aa..4d19d96 100644
--- a/util.mli
+++ b/util.mli
@@ -69,12 +69,18 @@ exception Undefined of string * json
       of bounds. *)
 
 val ( |> ) : 'a -> ('a -> 'b) -> 'b
-  (** Forward pipe operator; useful for composing JSON access functions
-      without too many parentheses *)
+(** @deprecated Forward pipe operator; useful for composing JSON
+    access functions without too many parentheses *)
 
-val keys: json -> string list
+val keys : json -> string list
   (** Returns all the key names in the given JSON object *)
 
+val values : json -> json list
+  (** Return all the value in the given JSON object *)
+
+val combine : json -> json -> json
+  (** Combine two JSON Objects together *)
+
 val member : string -> json -> json
   (** [member k obj] returns the value associated with the key [k] in the JSON
       object [obj], or [`Null] if [k] is not present in [obj]. *)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ocaml-maint/packages/yojson.git



More information about the Pkg-ocaml-maint-commits mailing list