失败:responseSerializationFailed(原因:Alamofire.AFError.ResponseSerializationFailureReason.inputDataNilOrZeroLength)

时间:2019-02-25 09:12:12

标签: ios json swift alamofire

我正在尝试使用Alamofire读取JSON。这是我的代码:

jQuery(document).on("click",".menu-item", function(){

    jQuery(".menu-item").closest(".menu").removeClass("menu-toggle-open").hide();
});

JSON是有效的,在Postman中一切正常,但是我无法使其工作。网络上的任何建议都没有帮助(将responseJSON更改为responseString / responseData,将JSONEncoding.default更改为URLEncoding.default,等等)

有人可以帮助我吗?

1 个答案:

答案 0 :(得分:0)

您应尝试在回复部分“预览”标签中的邮递员中查看回复。有时它会在“ Pretty”部分显示正确的json。但在“预览”部分中,许多包含API响应的一些打印语句。并且这些打印语句在json解码中造成问题。

enter image description here

此外,如果您想获得邮递员响应的快速代码,则始终可以从邮递员的代码功能中获取它:

enter image description here

enter image description here

希望这会有所帮助..!

相关问题