我使用FBSDK和Xcode 7.2.1来检索用户配置文件信息,并使用SwiftyJson来处理和操作json数据.在更改值/删除一些后,我想使用JSON数据向我的api发布请求.但是我很快就遇到了非常糟糕的类型问题.
这是我发布帖子请求的代码:
let headers = [
"Content-Type": "application/json"
]
let userProfile = userProfile as? [String : AnyObject]
Alamofire.request(.POST, "http://localhost:8888/api/profile", parameters: userProfile, headers: headers, encoding:ParameterEncoding.URL) .response { request, response, data, error in
print(userProfile) //This prints nil
print(response) //This prints api error for expecting data
}
Run Code Online (Sandbox Code Playgroud)
不幸的是我收到此错误:
从'JSON'转换为不相关的类型'[String:AnyObject]'总是失败
如果我尝试将JSON数据直接发送到API,我会收到此错误:
无法将'JSON'类型的值转换为预期的参数类型'[String:AnyObject]?'
任何帮助表示赞赏.我只是想知道,如何将JSON对象转换为String AnyObject?没有失败.或者使用Swift 2将Json对象作为post/put/patch请求数据发送.
我在OSX 10.9上使用Xamppp for macos with Php 5.4.19我安装了oracle instantclient,我可以看到oci8在phpinfo中启用(如下):
OCI8支持已启用 版本1.4.9修订版$ Id:44bfa713983a99b3e59477f6532e5fb51b6dee94 $活动持久连接0活动连接0
我可以看到DYLD_LIBRARY_PATH也是在我的phpinfo中设置的.
DYLD_LIBRARY_PATH /usr/local/instantclient/11.2.0.3
但是当我尝试连接php时,我现在有两天同样的错误:(
警告:oci_connect():OCIEnvNlsCreate()失败.系统出现问题 - 请检查DYLD_LIBRARY_PATH是否包含第6行的info.php中带有Oracle Instant Client库的目录警告:oci_connect():尝试在info.php中检索错误ORA-01804时出错6
任何帮助都会很棒.谢谢.