Loosen JSON list parsing
This commit is contained in:
parent
482bc9ecb6
commit
82ae6dbc33
1 changed files with 7 additions and 5 deletions
12
config.ml
12
config.ml
|
@ -38,9 +38,11 @@ module Addrs = struct
|
|||
&> (str |> name)
|
||||
end
|
||||
|
||||
let to_list_loose = function `List list -> list | _ -> []
|
||||
|
||||
let to_int_list json =
|
||||
let open Yojson.Basic.Util in
|
||||
json |> to_list |> List.map to_int
|
||||
json |> to_list_loose |> List.map to_int
|
||||
|
||||
module PayloadRule = struct
|
||||
module Tcp = struct
|
||||
|
@ -74,9 +76,7 @@ module PayloadRule = struct
|
|||
| _ -> assert false
|
||||
end
|
||||
|
||||
let to_addr_list json =
|
||||
let open Yojson.Basic.Util in
|
||||
json |> to_list |> List.map Addrs.of_json
|
||||
let to_addr_list json = json |> to_list_loose |> List.map Addrs.of_json
|
||||
|
||||
module Rule = struct
|
||||
type t = { src : Addrs.t list; dest : Addrs.t list; payload : PayloadRule.t }
|
||||
|
@ -98,5 +98,7 @@ let zones_of_json json =
|
|||
let of_json json =
|
||||
let open Yojson.Basic.Util in
|
||||
let zones = json |> member "zones" |> zones_of_json in
|
||||
let rules = json |> member "rules" |> to_list |> List.map Rule.of_json in
|
||||
let rules =
|
||||
json |> member "rules" |> to_list_loose |> List.map Rule.of_json
|
||||
in
|
||||
{ zones; rules }
|
||||
|
|
Loading…
Reference in a new issue