RxCodable icon indicating copy to clipboard operation
RxCodable copied to clipboard

add toDictionary, toJSONString

Open iamchiwon opened this issue 8 years ago • 2 comments

My project using Firebase, needs convertings between Model and Dictionary, [String:Any]. So I added "toDictionary()" and "toJSONString()" for POST request

  1. when error occured, toDictionay() and toJSONString() returns empty not nil , followed your map() that returns empty Data when error
  2. respected your coding convention, 2 space indent, and space after colon

iamchiwon avatar Jan 02 '18 06:01 iamchiwon

Codecov Report

Merging #2 into master will decrease coverage by 4.87%. The diff coverage is 83.56%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master       #2      +/-   ##
==========================================
- Coverage    92.5%   87.62%   -4.88%     
==========================================
  Files           4        3       -1     
  Lines          40       97      +57     
  Branches        3        0       -3     
==========================================
+ Hits           37       85      +48     
- Misses          0       12      +12     
+ Partials        3        0       -3
Impacted Files Coverage Δ
Sources/RxCodable/ObservableType+RxCodable.swift 87.09% <82.6%> (-3.82%) :arrow_down:
Sources/RxCodable/Single+RxCodable.swift 87.87% <84%> (-3.04%) :arrow_down:
Sources/RxCodable/Maybe+RxCodable.swift 87.87% <84%> (-3.04%) :arrow_down:
Sources/TestUtil/Fixture.swift

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 3e4c053...ef78616. Read the comment docs.

codecov-io avatar Jan 02 '18 06:01 codecov-io

  1. toDictionary(), toJSONString() got parameter JSONEncoder as first with no name.
  2. toDoctionary() throws RxError.noElements. RxError.noElements seems not exactly matched, but I don't want to create new ErrorType
  3. UnitTest added, that shows [Encodable] ==> JSON string.

iamchiwon avatar Jan 03 '18 04:01 iamchiwon