FundingCircle / jackdaw

A Clojure library for the Apache Kafka distributed streaming platform.
https://fundingcircle.github.io/jackdaw/
BSD 3-Clause "New" or "Revised" License
369 stars 80 forks source link

Open up the coercion stack #224

Closed cddr closed 4 years ago

cddr commented 4 years ago

A few people have noticed that the JSON representation of an avro object is a bit different to the edn representation of an avro object. This behaviour was originally copied from the abracad.avro project but it makes it a little bit inconvenient to work with data obtained via more "avro-oriented" tools like the kafka-avro-console-consumer or the avro-random-generator.

The pair of functions in this PR make it a bit easier to convert between these two representations.

Example Usage

as-json

(as-json {:avro-schema (clojure.data.json/write-str ["null" "string"])}
          "yolo")
=> "{\"string\":\"yolo\"}"

as-edn

(as-edn {:avro-schema (clojure.data.json/write-str ["null" "string"])}
        "{\"string\":\"yolo\"}")
=> "yolo"

Checklist

codecov[bot] commented 4 years ago

Codecov Report

Merging #224 into master will decrease coverage by 0.22%. The diff coverage is 96.96%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #224      +/-   ##
==========================================
- Coverage   79.97%   79.74%   -0.23%     
==========================================
  Files          42       42              
  Lines        2597     2622      +25     
  Branches      150      151       +1     
==========================================
+ Hits         2077     2091      +14     
- Misses        370      380      +10     
- Partials      150      151       +1
Impacted Files Coverage Δ
src/jackdaw/serdes/avro.clj 88.5% <96.96%> (+0.58%) :arrow_up:
src/jackdaw/serdes/edn2.clj 45.45% <0%> (-45.46%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update d6a58fb...452eeff. Read the comment docs.

AndreaCrotti commented 4 years ago

No tests yet.

You can remove that from the description of the PR since you added them