Skip to content

Unable to call toJSON on multi-dimensional arrays #80

@fontduroy

Description

@fontduroy

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions