diff --git a/src/dune b/src/dune index eff1191..f4802b2 100644 --- a/src/dune +++ b/src/dune @@ -18,6 +18,7 @@ user user_profile) (libraries + yojson uuidm caqti.blocking caqti-driver-sqlite3 diff --git a/src/pp_babillard.ml b/src/pp_babillard.ml index 4fb8c46..9b0f377 100644 --- a/src/pp_babillard.ml +++ b/src/pp_babillard.ml @@ -190,20 +190,22 @@ let get_markers () = let markers = List.map Result.get_ok (List.filter Result.is_ok markers_res) in let pp_marker fmt (lat, lng, content, thread_id) = - Format.fprintf fmt - {|{ - "type": "Feature", - "geometry": { - "type": "Point", - "coordinates": [%s,%s] - }, - "properties": { - "content": "%s", - "thread_id": "%s" - }}|} - (* geojson use lng lat, and not lat lng*) - (Float.to_string lng) - (Float.to_string lat) (String.escaped content) thread_id + (* geojson use lng lat, and not lat lng*) + let json = + `Assoc + [ ("type", `String "Feature") + ; ( "geometry" + , `Assoc + [ ("type", `String "Point") + ; ("coordinates", `List [ `Float lng; `Float lat ]) + ] ) + ; ( "properties" + , `Assoc + [ ("content", `String content); ("thread_id", `String thread_id) ] + ) + ] + in + Yojson.pretty_print fmt json in let markers = Format.asprintf "[%a]"