Skip to content

Commit

Permalink
(piqi,ocaml,erlang) json-omit-null-fields now works for repeated fiel…
Browse files Browse the repository at this point in the history
…ds as well

The json-omit-null-fields setting, when true, leads to non-existent repeated
fields being omitted from JSON output (in addition to missing optinal fields).
Before this change, they were included and had [] as a value.
  • Loading branch information
alavrik committed Oct 8, 2012
1 parent 7e16806 commit 08d6d7c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions piqilib/piqobj_to_json.ml
Expand Up @@ -105,9 +105,12 @@ and gen_field fields t =
)
| `repeated ->
let fields = List.find_all pred fields in
let json_fields = List.map (fun f -> gen_obj (some_of f.obj)) fields in
let res = make_named name (`List json_fields) in
[res]
if fields = [] && !omit_null_fields
then []
else
let json_fields = List.map (fun f -> gen_obj (some_of f.obj)) fields in
let res = make_named name (`List json_fields) in
[res]


and gen_variant x =
Expand Down

0 comments on commit 08d6d7c

Please sign in to comment.