Decoding dynamic JSON structure in swift 4

后端 未结 4 1559
情深已故
情深已故 2021-01-28 16:43

I have the following issue that I\'m not sure how to handle.

My JSON response can look like this:

{ 
  \"data\": {
      \"id\": 7,
      \"         


        
4条回答
  •  孤独总比滥情好
    2021-01-28 17:13

    If you have only two possible outcomes for your data, an option would be to try and parse data to one of the expected types, if that fails you know that the data is of other type and you can then handle it accordingly.

    See this

提交回复
热议问题