Skip to content

Conversation

Woollim
Copy link

@Woollim Woollim commented Aug 4, 2020

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

}
return try? JSONDecoder().decode(T.self, from: data)
} else {
guard let data = try? JSONSerialization.data(withJSONObject: ["value": item], options: []) else {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wrote Single Value parsing code by referring to Moya's code.
Link: Moya/Response.swift/Line-167

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant