udpated constructors for JSONDecoder

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2022-05-10 12:11:48 -05:00
parent a59560e37b
commit 33100758b8
2 changed files with 2 additions and 9 deletions

View File

@ -33,11 +33,7 @@ public extension TemplateProtocol {
guard let pageJSON = json else { return }
let delegateObject = (self as? MVMCoreViewControllerProtocol)?.delegateObject?() as? MVMCoreUIDelegateObject
let data = try JSONSerialization.data(withJSONObject: pageJSON)
let decoder = JSONDecoder()
if let delegateObject = delegateObject {
// Add the delegate to access mid parsing if applicable.
try decoder.add(delegateObject: delegateObject)
}
let decoder = try JSONDecoder.create(delegateObject: delegateObjectIVar)
templateModel = try decodeTemplate(using: decoder, from: data)
// Add additional required behaviors if applicable.

View File

@ -69,10 +69,7 @@ open class TopNotificationModel: Codable {
/// Decodes the top alert json to a model.
public static func decode(json: [AnyHashable: Any], delegateObject: MVMCoreUIDelegateObject?) throws -> Self {
let data = try JSONSerialization.data(withJSONObject: json)
let decoder = JSONDecoder()
if let delegateObject = delegateObject {
try decoder.add(delegateObject: delegateObject)
}
let decoder = try JSONDecoder.create(delegateObject: delegateObject)
return try decoder.decode(self, from: data)
}