Upgrade to Pro — share decks privately, control downloads, hide ads and more …

実践的な Reader Conditionals と Transit format

ayato
December 20, 2015

実践的な Reader Conditionals と Transit format

ayato

December 20, 2015
Tweet

More Decks by ayato

Other Decks in Programming

Transcript

  1. (ns example.core #?(:clj (:import [java.net URLEncoder]))) (defn url-encode [string] (some->

    string str #?(:clj (URLEncoder/encode "UTF-8") :cljs (js/encodeURIComponent)) (.replace "+" "%20"))) 3FBEFS$POEJUJPOBMT
  2. (ns example.core (:require [cognitect.transit :as transit]) (:import [java.io ByteArrayInputStream ByteArrayOutputStream]))

    (def writer (transit/writer out :json)) (transit/write writer [{:name "ayato_p" :age 24} {:name "alea" :age 24}]) (prn (.toString out)) ;; => "[[\"^ \",\"~:name\",\"ayato_p\",\"~:age\",24], [\"^ \",\"^0\",\"alea\",\"^1\",24]]" 5SBOTJUGPSNBU