$30 off During Our Annual Pro Sale. View Details »

実践的な 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. 1SBDUJDBM 3FBEFS$POEJUJPOBMT  5SBOTJUGPSNBU -JTQ.FFU6QQSFTFOUFECZ4IJCVZBMJTQ
 !@BZBUP@Q

  2. ͋΍ͽʔ $MPKVSFŧŔŕŪƂŜſŵƃ ීஈ͸$MPKVSFũƄŝſŵƃͱ࢓ࣄͯ͠Δ $MPKVSFŜŝŦŘŵƃ୳ͯ͠·͢ $ZCP[V4UBSUVQT *OD

  3. ࠓ೔͢Δ࿩ 3FBEFS$POEJUJPOBMTͱ5SBOTJUGPSNBU
 ͷݱ࣮తͳ׆༻ํ๏ʹ͍ͭͯ

  4. &13FBEFS$POEJUJPOBMT ͋Δ೔ͷ͜ͱʜ ๻ʮ3FBEFS$POEJUJPOBMTศརͰ͢ΑͶʔʯ "MJDFʮͲ͏͍͏ͱ͖ʹ࢖͏ΜͰ͔͢ʁʯ ๻ʮ͑ʯ "MJDFʮόϦσʔγϣϯͱ͔ʁʯ

  5. 3FBEFS$POEJUJPOBMT ʹ͍ͭͯ

  6. 3FBEFS$POEJUJPOBMTͱ͸ $MPKVSF͔Βͷػೳ 3FBEFSTZOUBY   ! Λ࢖ͬͯ
 ϓϥοτϑΥʔϜґଘΛ੾Γग़͢͜ͱ͕ग़དྷΔ ֦ுࢠΛDMKDͱ͢Δ͜ͱͰ
 ֤ϓϥοτϑΥʔϜ͔Βݺͼग़ͤΔ

    ओʹϥΠϒϥϦ։ൃͰॏๅ͢Δ
 CJEJ DMKTBKBY FUD
  7. (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
  8. Ͳ͏͍͏ͱ͖ʹ࢖͑Δʁ ϧʔτఆٛͷڞ༗ αʔόʔαΠυϨϯμϦϯάGPS3FBHFOU ϞσϧͷόϦσʔγϣϯݕࠪ

  9. %&.0

  10. &15SBOTJUGPSNBU ͋Δ೔ͷ͜ͱ ๻ʮ5SBOTJUGPSNBU࠷ߴͰ͢ΑͶʂʯ #PCʮ+40/ͱԿ͕ҧ͏ΜͰ͔͢ʁʯ ๻ʮ͑ʯ #PCʮ+40/Ͱྑ͘ͳ͍Ͱ͢ʁʯ

  11. 5SBOTJUGPSNBU ʹ͍ͭͯ

  12. 5SBOTJUGPSNBUͱ͸ $PHOJUFDU͕ఏএ͢ΔσʔλϑΥʔϚοτ ϓϩάϥϜͱϓϩάϥϜͷίϛϡχέʔγϣϯ
 ʹϑΥʔΧε͍ͯ͠Δ ֦ுੑ͕ߴ͘ɺϢʔβʔఆٛܕΛอ࣋ग़དྷΔ +40/ .FTTBHF1BDLͱޓ׵ੑ͕͋Δ 3FBEFS$POEJUJPOBMTͱ૬ੑ͕ྑ͍

  13. (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
  14. Ͳ͏͍͏ͱ͖ʹ࢖͑Δʁ $MPKVSFͱ$MPKVSF4DSJQUؒͷ௨৴

  15. %&.0

  16. ·ͱΊ 3FBEFS$POEJUJPOBMT΍5SBOTJUGPSNBUศར $MPKVSF࠷ߴʂʂ

  17. Enjoy Clojure