JSONCodable icon indicating copy to clipboard operation
JSONCodable copied to clipboard

Unable to call toJSON on multi-dimensional arrays

Open fontduroy opened this issue 8 years ago • 0 comments

Perhaps I'm missing something, but it doesn't seem like multi-dimensional arrays are supported with the JSONEncodable protocol. For example, this test fails:

class TwoDimensionalArrayClass: JSONEncodable {
    var array2D: [[String]]?
}

class JSONCodableTests: XCTestCase {
    
    func testTwoDimensionalArray() {

        let twoDim = TwoDimensionalArrayClass()
        twoDim.array2D = [["One", "Two", "Three"], ["Four", "Five", "Six"], ["Seven", "Eight", "Nine"]]
        
        do {
            try twoDim.toJSON()
        }
        catch {
            print(error)
            XCTFail()
        }
    }
}

Any help or suggestion would be greatly appreciated.

fontduroy avatar May 26 '17 20:05 fontduroy