A fork of mtelver's day10 project

Add json_packages.ml

+14
+14
bin/json_packages.ml
··· 1 + type package_list = { 2 + packages: string list; 3 + } [@@deriving yojson] 4 + 5 + let read_packages filename = 6 + let json = Yojson.Safe.from_file filename in 7 + match package_list_of_yojson json with 8 + | Ok { packages } -> packages 9 + | Error msg -> failwith (Printf.sprintf "Failed to parse package list from %s: %s" filename msg) 10 + 11 + let write_packages filename packages = 12 + let package_list = { packages } in 13 + let json = package_list_to_yojson package_list in 14 + Yojson.Safe.to_file filename json