Created
July 11, 2020 03:04
-
-
Save dvliman/2639f5c7d6b9a5da32f00cf15cce80f0 to your computer and use it in GitHub Desktop.
cheshire serialize org.postgresql.geometric PGpoint
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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