Displaying 7 results from an estimated 7 matches for "json_string_escape".
2014 Oct 10
0
[PATCH 3/3] builder: use the JSON module
...2 +97,64 @@ and list_entries_long ~sources index =
) index
and list_entries_json ~sources index =
- let trailing_comma index size =
- if index = size - 1 then "" else "," in
- let json_string_of_bool b =
- if b then "true" else "false" in
- let json_string_escape str =
- let res = ref "" in
- for i = 0 to String.length str - 1 do
- res := !res ^ (match str.[i] with
- | '"' -> "\\\""
- | '\\' -> "\\\\"
- | '\b' -> "\\b"
- | '\n' -...
2014 Jan 22
1
[PATCH] builder: small code simplification
...ex =
| c -> String.make 1 c)
done;
!res in
- let json_optional_printf_string key value =
- match value with
+ let json_optional_printf_string key = function
| None -> ()
| Some str ->
printf " \"%s\": \"%s\",\n" key (json_string_escape str) in
- let json_optional_printf_int64 key value =
- match value with
+ let json_optional_printf_int64 key = function
| None -> ()
| Some n ->
printf " \"%s\": \"%Ld\",\n" key n in
--
1.8.3.1
2014 Jan 16
0
[PATCH 3/3] builder: add a JSON output for --list
...es index =
printf "\n"
)
) index
+
+and list_entries_json ~sources index =
+ let trailing_comma index size =
+ if index = size - 1 then "" else "," in
+ let json_string_of_bool b =
+ if b then "true" else "false" in
+ let json_string_escape str =
+ let res = ref "" in
+ for i = 0 to String.length str - 1 do
+ res := !res ^ (match str.[i] with
+ | '"' -> "\\\""
+ | '\\' -> "\\\\"
+ | '\b' -> "\\b"
+ | '\n' -...
2014 Jan 30
2
[PATCH] builder: output translated notes
...@ -108,10 +139,20 @@ and list_entries_json ~sources index =
| Some n ->
printf " \"%s\": \"%Ld\",\n" key n in
let print_notes = function
- | ("", notes) :: _ ->
- printf " \"notes\": \"%s\",\n" (json_string_escape notes)
- | _ :: _
- | _ -> () in
+ | [] -> ()
+ | notes ->
+ printf " \"notes\": {\n";
+ iteri (
+ fun i (lang, langnotes) ->
+ let lang =
+ match lang with
+ | "" -> "C"
+...
2014 Oct 10
4
[PATCH 1/3] Move JSON to mllib
Move the simple OCaml JSON writer to mllib, so that can be enhanced and
used also outside v2v.
---
mllib/JSON.ml | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++
mllib/JSON.mli | 26 ++++++++++++++++++++++++++
mllib/Makefile.am | 5 ++++-
po/POTFILES-ml | 2 +-
v2v/JSON.ml | 53 -----------------------------------------------------
v2v/JSON.mli | 26
2014 Jan 16
5
[PATCH 0/3] Add JSON output for virt-builder
Hi,
This small patch serie adds a JSON output for virt-builder.
This way it is possible to parse the list of available templates,
with no need to parse the unstructured and possibly changing short and
long outputs of virt-builder.
Pino Toscano (3):
builder: small refactor of the list output
builder: add --list-format
builder: add a JSON output for --list
builder/builder.ml
2014 Jan 22
2
[PATCH] builder: read all the available notes from the index
...and list_entries_json ~sources index =
| None -> ()
| Some n ->
printf " \"%s\": \"%Ld\",\n" key n in
+ let print_notes = function
+ | ("", notes) :: _ ->
+ printf " \"notes\": \"%s\",\n" (json_string_escape notes)
+ | _ -> () in
printf "{\n";
printf " \"version\": %d,\n" 1;
@@ -132,7 +136,7 @@ and list_entries_json ~sources index =
json_optional_printf_string "full-name" printable_name;
printf " \"size\": %Ld,\n&quo...