Skip to content

Commit

Permalink
🐛 :: XML을 Response로 받던 현상 해결
Browse files Browse the repository at this point in the history
  • Loading branch information
baekteun committed Jul 16, 2023
1 parent f475f32 commit b97342f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Sources/NeiSwift/Protocol/NeisRequestable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public extension NeisRequestable where Self: HasURLSession, Self: HasNeisParser,

if let data {
do {
let json = try JSONSerialization.jsonObject(with: data) as? [String: Any] ?? [:]
let json = try JSONSerialization.jsonObject(with: data, options: .fragmentsAllowed) as? [String: Any] ?? [:]
let response: T = try neisParser.parse(json: json, key: "\(key)")
completion(.success(response))
} catch {
Expand Down
6 changes: 5 additions & 1 deletion Sources/NeiSwift/Public/NeisProtocol+Impl.swift
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,13 @@ public extension NeisProtocol where Self: NeisRequestable {

private extension Dictionary where Key == String, Value == Any {
func buildParameters() -> [URLQueryItem] {
self.reduce(into: [URLQueryItem]()) { partialResult, dict in
var parameters = self.reduce(into: [URLQueryItem]()) { partialResult, dict in
guard let value = dict.value as? String else { return }
partialResult.append(URLQueryItem(name: dict.key, value: value))
}
parameters.append(
URLQueryItem(name: "Type", value: "json")
)
return parameters
}
}
2 changes: 1 addition & 1 deletion Sources/NeiSwift/Public/Response/MealInfoResponse.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public struct MealInfoResponse: Codable {
/// 급식일자
public let MLSV_YMD: String
/// 급식인원수
public let MLSV_FGR: String
public let MLSV_FGR: Int
/// 요리명
public let DDISH_NM: String
/// 원산지정보
Expand Down

0 comments on commit b97342f

Please sign in to comment.