Vibe-coded JSON library
Written in ante
text = "{\"id\":9007199254740993,\"name\":\"ante\"}"
// parse
match jd_parse (bs_from_string (ref text)) (parse_opts_default ())
| Error e ->
(line, col) = jsonerr_line_col (bs_from_string (ref text)) (err_offset (ref e))
println "parse failed at line ${line}, column ${col}"
| Ok (doc, root) ->
if jd_tag (ref doc) root == jt_obj () then
match jd_obj_get (ref doc) root (ref "id")
| None -> println "no id"
| Some id -> println "id ${id}"
// serialize
match jd_ser (ref doc) root
| Error _ -> println "not serializable"
| Ok out -> println out
(drop calls omitted for brevity)