Skip to content

Instantly share code, notes, and snippets.

@dvliman
Created July 11, 2020 03:04
Show Gist options
  • Save dvliman/2639f5c7d6b9a5da32f00cf15cce80f0 to your computer and use it in GitHub Desktop.
Save dvliman/2639f5c7d6b9a5da32f00cf15cce80f0 to your computer and use it in GitHub Desktop.
cheshire serialize org.postgresql.geometric PGpoint
(ns plokal.cheshire
(:require [cheshire.generate :refer [add-encoder]]
[cheshire.core :as json])
(:import [com.fasterxml.jackson.core JsonGenerator]
(org.postgresql.geometric PGpoint)))
(add-encoder
PGpoint
(fn [^PGpoint data ^JsonGenerator jsonGenerator]
(.writeString jsonGenerator (json/generate-string {:type :Point
:coordinates [(.x data) (.y data)]}))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment