tristanhimmelman / ObjectMapper

Simple JSON Object mapping written in Swift
MIT License
9.16k stars 1.03k forks source link

Fix JSON Parsing Issues in `CodableTransform` #1103

Open Woollim opened 4 years ago

Woollim commented 4 years ago

Why

  1. Problem occurred when trying to parse the JSON Array. 스크린샷 2020-08-04 오후 6 00 47
let json = ["array_value": [1, 2, 3, 4, 5]]
// not working! 🙀
self.array = try map.value("array_value", using: CodableTransform<[Int]>())
  1. Problem occurred when trying to parse single JSON value using Key Path. 스크린샷 2020-08-04 오후 6 00 36
let json = ["int_value": 1]
// not working too! 🙀
self.value = try map.value("int_value", using: CodableTransform<Int>())

What

  1. Fix transformFromJSON function logic in CodableTransform.swift
  2. Add test case for JSON Array, Single Value From JSON Object parsing