OCaml library for JSONfeed parsing and creation
1(** Simple test to demonstrate JSON serialization works *) 2 3open Jsonfeed 4 5let () = 6 (* Create a simple feed *) 7 let author = Author.create ~name:"Test Author" () in 8 let item = Item.create 9 ~id:"https://example.com/1" 10 ~title:"Test Item" 11 ~content:(`Html "<p>Hello, world!</p>") 12 () in 13 14 let feed = Jsonfeed.create 15 ~title:"Test Feed" 16 ~home_page_url:"https://example.com" 17 ~authors:[author] 18 ~items:[item] 19 () in 20 21 (* Serialize to JSON *) 22 let json = Jsonfeed.to_string feed in 23 24 (* Print it *) 25 Printf.printf "Generated JSON Feed:\n%s\n\n" json; 26 27 (* Validate *) 28 match Jsonfeed.validate feed with 29 | Ok () -> Printf.printf "✓ Feed is valid\n" 30 | Error errors -> 31 Printf.printf "✗ Feed has errors:\n"; 32 List.iter (Printf.printf " - %s\n") errors