- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
来自 MockURL200Session 的传入 JSON 生成值 2017-11-25 09:47:18 Etc/GMT
。
class MockURL200Session: URLSessionProtocol {
var nextDataTask = MockURLSessionDataTask()
var nextData: Data?
var nextError: Error?
func httpURLResponse(request: NSURLRequest) -> URLResponse {
return HTTPURLResponse(url: request.url!, statusCode: 200, httpVersion: "HTTP/1.1", headerFields: nil)!
}
func dataTask(with request: NSURLRequest, completionHandler: @escaping DataTaskResult) -> URLSessionDataTaskProtocol {
let json = ["expires_date": "2017-11-25 09:47:18 Etc/GMT"]
nextData = try! JSONSerialization.data(withJSONObject: json, options: [])
completionHandler(nextData, httpURLResponse(request: request), nextError)
return nextDataTask as URLSessionDataTaskProtocol
}
}
但是,一旦到达客户端,正斜杠就会消失并变为 2017-11-25 09:47:18 Etc GMT
self.httpClient.post(url: url) { (data, response, error) in
let json = try! JSONSerialization.jsonObject(with: data!, options: []) as! Dictionary<String, Any>
}
我该如何防止或避免它?
最佳答案
在 dataTask()
中,您对 JSONSerialization.data()
的调用在解码时会转义正斜杠。在从 dataTask()
返回之前,您可以在 nextData
中看到它。在返回客户端的过程中,\/
组合被删除了。我猜是在您尝试解码服务器响应时。现在您知道发生了什么,您可以找到解决其余问题的方法 here ,或者如果没有,谷歌类似“swift jsonserialization escape slash”之类的东西。祝你好运。
关于swift - 为什么 JSON 序列化省略了 JSON 字符串中的正斜杠?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49308664/
我有一个右下角倾斜的元素,我必须在其上放置一个盒子阴影。有时倾斜的 Angular 被徽章覆盖 - 我的问题不适用,如果是这样的话: 这是信息框及其边 Angular 的 (s)css 部分(还有更多
是否可以在纯 html/css 中创建类似下面的内容? 我想做这个响应式和全 (100%) 宽度(最大左 Angular 100 像素,右边最小 50 像素,类似的东西)。 最佳答案 您可以通过转换(
如何在 fabricjs 文本中为文本提供渐变或斜 Angular 效果?? http://fabricjs.com/fabric-intro-part-2/ 这里给出了形状和所有示例,我将其与文本绑
我用过: http://apps.eky.hk/css-triangle-generator/ 为彼此对 Angular 放置的两个不等边三 Angular 形生成 css: 左下三 Angular
我是一名优秀的程序员,十分优秀!