SWIFT 5 JSONDecoder解码带有空格的字段名JSON例如帖子标题:Hello World&Quot;

问题描述我目前正在使用JSONDecoder在Swift5中将JSON解析为对象。我现在才意识到JSON的一部分是糟糕的JSON。它有一个带有空格的字段名:"帖子标题"。我不确定为什么会是这样,我知道这样设置JSON是不好的做法,但在JSON方面我无能为力。有没有办法使用JSON

发布:2022-10-16 标签:jsonswiftswift5jsondecoder


更新响应JSON以响应SWIFT中的可解码响应

问题描述我是SWIFT新手,我正在尝试升级一些旧的SWIFT代码。我收到以下警告:‘responseJSON(queue:dataPreprocessor:emptyResponseCodes:emptyRequestMethods:options:completionHandl

发布:2022-10-16 标签:iosswiftalamofirejsondecoder


编码/解码时 UIImage 不等效

问题描述我一直在对我的模型进行一些测试,以确保当我将它们编码为JSON然后使用JSONEncoder/Decoder将它们解码回来时它们是相等的.但是,我的一项测试失败了,罪魁祸首是UIImage.我确保在编码/解码过程中没有抛出任何错误.I'vebeendoingsometes

发布:2022-10-16 标签:jsonswiftuiimageequatablejsondecoder


使用可编码解码JSON数组-Swift 5

问题描述我想在以下链接中解码json数据Iwouldliketodecodethejsondatainthefollowinglinkhttps://stats.nba.com/stats/assistleaders?LeagueID=00&PerMode=Totals&Play

发布:2022-10-16 标签:jsonarraysswiftjsondecoder


解析复杂的JSON,其中数据和“列标头"在单独的数组中

问题描述我有以下从API获取的JSON数据:IhavethefollowingJSONdataIgetfromanAPI:{"datatable":{"data":[["John","Doe","1990-01-01","Chicago"],["Jane","Doe","2000

发布:2022-10-16 标签:jsonjson-deserializationswiftjsondecoder


快速解码复合结构数据

问题描述我有以下json数据并尝试对其进行解析,但是我得到了许多对象,但是数组中的对象本身均为nil.Ihavethefollowingjsondataandtryingtoparseit,butIgetnumberofobjects,butobjectitselfinthear

发布:2022-10-16 标签:decodeswiftjsondecoder


Swift 4 JSONDecoder可选变量

问题描述我有一个Codable结构myObj:publicstructVIO:Codable{letid:Int?;...varpar1:Bool=false;//defaulttoavoiderrorinparsingvarpar2:Bool=false;}当我收到JSON时,

发布:2022-10-16 标签:swift4swiftjsondecoder


Swift Decodable,端点返回完全不同的类型

问题描述在使用我正在使用的API的情况下,根据调用是否成功,一个API端点可以返回完全不同的响应.如果成功,API端点将在根中返回一个请求的对象数组,如下所示:WithAPII'mworkingwith,Ihaveacasewhere1APIEndpointcanreturnco

发布:2022-10-16 标签:swiftswift-extensionscodabledecodablejsondecoder


JSONDecoder无法解码* Mac *上的* value/fragment *类型

问题描述有人知道配置>的Mac版本以使其能够decode片段/值类型的方法吗?DoesanyoneknowofawaytoconfiguretheMacversionofJSONDecodersothatitisabletodecodefragment/valuetypes?我正

发布:2022-10-16 标签:swiftmacosjsondecoder


在Swift中使用Codable时如何保持灵活的结构

问题描述我有一个表示用户对象的API响应结构,如下所示:I'vegotaAPIresponsestructure,representingauserobject,thatlookslikethis:{"statuscode":200,"response_type":3,"erro

发布:2022-10-16 标签:swiftcodablejsondecoder