Below is the code,
//Controller.swift
struct MyObject {
init(myJson: JSON) {
// some code here
}
}
//unittest.swift
let json = JSON("{}")
let obj = MyObject(myJson: json)
I get the error Cannot convert value of type 'JSON' to expected argument type 'JSON'
Note: However, this does not happen when I put the struct in the same unit test file. Using SwiftyJSON library for JSON parsing
I got this error when I forgot to convert from JSON to Swift representation of the data type. Hope this example helps.
For example:
let someString = json["name"].string
let someArray = json["products"].arrayObject