diff --git a/MVMCore/MVMCore/Models/Extensions/Encoder.swift b/MVMCore/MVMCore/Models/Extensions/Encoder.swift index 9f50bc3..832059b 100644 --- a/MVMCore/MVMCore/Models/Extensions/Encoder.swift +++ b/MVMCore/MVMCore/Models/Extensions/Encoder.swift @@ -34,6 +34,15 @@ extension Encodable { return jsonAny } + public func toJSONArray() throws -> [Any] { + let data = try self.encode() + let json = try JSONSerialization.jsonObject(with: data, options: .allowFragments) + guard let jsonArray = json as? [Any] else { + throw JSONError.error(message: "JSON Array not found") + } + return jsonArray + } + public func toJSONString() -> String? { guard let json = self.toJSON(), let data = try? JSONSerialization.data(withJSONObject: json, options: .prettyPrinted),