Commit cf9d2674 authored by Grégoire Henry's avatar Grégoire Henry

Shell/RPC: allow immediate value

This a HACK for allowing serialisation of toplevel value that are
float, string,... and not only object or array.

In a latter time, we may prefer to you `yojson` instead of `ezjsonm`,
but some of our dependencies rely on `ezjsonm` and we may not want to
embeds two distinct JSON libraries...
parent 556e95ce
Pipeline #22830124 passed with stages
in 18 minutes and 3 seconds
......@@ -274,13 +274,16 @@ let to_root = function
| `Null -> `O []
| oth -> `A [ oth ]
let to_string ?minify j = Ezjsonm.to_string ?minify (to_root j)
let to_string ?minify j =
Format.asprintf "%a" Json_repr.(pp ?compact:minify (module Ezjsonm)) j
let pp = Json_repr.(pp (module Ezjsonm))
let from_string s =
try Ok (Ezjsonm.from_string s :> json)
with Ezjsonm.Parse_error (_, msg) -> Error msg
match Ezjsonm.from_string ("[" ^ s ^ "]") with
| exception Ezjsonm.Parse_error (_, msg) -> Error msg
| `A [ json ] -> Ok json
| _ -> Error "Malformed value"
let from_stream (stream: string Lwt_stream.t) =
let buffer = ref "" in
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment