I have some error not undestand.. Well i send this code
JSONARRAY {
JSON,
JSONARRAY,
JSONARRAY
}
Y have this but not working or not parse correct, no matter for while the two array is not adding anything
buscarEmpresa=[
"{\n \"criterio\" : \"fru\",\n \"tipo\" : \"0\",\n \"idempresa\" : \"82\"\n}",
[
],
[
]
]
The data couldn’t be read because it isn’t in the correct format.
try this code..
let usuario = UsuarioSQL.getUsuario()!
var jArray: [AnyObject] = []
let jUsuario = NSMutableDictionary()
jUsuario.setValue((phBuscar.text?.trimmingCharacters(in: .whitespacesAndNewlines))!, forKey: "criterio")
jUsuario.setValue(String(describing: usuario.tipo_negocio), forKey: "tipo")
jUsuario.setValue(String(describing: usuario.id_server), forKey: "idempresa")
let jData = try! JSONSerialization.data(withJSONObject: jUsuario, options: .prettyPrinted)
let jStr = NSString(data: jData, encoding: String.Encoding.utf8.rawValue) as! String
jArray.append(jStr as AnyObject)
let jaEmpresarial = NSMutableArray()
for i in receive_empresarial {
let jEmpresarial = NSMutableDictionary()
jEmpresarial.setValue(i, forKey: "empresarial")
jaEmpresarial.add(jEmpresarial)
}
jArray.append(jaEmpresarial)
let jaPais = NSMutableArray()
for i in receive_paises {
let jPais = NSMutableDictionary()
jPais.setValue(i, forKey: "pais")
jaPais.add(jPais)
}
jArray.append(jaPais)
let post = try! JSONSerialization.data(withJSONObject: jArray, options: .prettyPrinted)
let jPost = NSString(data: post, encoding: String.Encoding.utf8.rawValue) as! String
let sesion = URLSession.shared
let parameters = "buscarEmpresa=\(jPost)"
print(parameters)
NSArrayandNSDictionaryin Swift code ...