How to include null value in the JSON via NSJSONSerialization?

前端 未结 4 668
情深已故
情深已故 2020-12-30 22:25

I think I get it how to use the NSJSONSerialization over all. The call I am making is:

[NSJSONSerialization dataWithJSONObject:parameters options:0 error:&a         


        
4条回答
  •  Happy的楠姐
    2020-12-30 22:57

    If you are using Swifty JSON, I've just created a PR that should handle nil. It's not merged yet and might need some improvements. The part that describes how to do that should be a good start to write your own implementation if you need to. The logic is not that complicated but there might be tricky edge cases/performance things to think about.

    I know it's not a direct response to the question since it's replacing NSJSONSerialization, but I hope it can help some people frustrated by how Swift handles nil/json!

提交回复
热议问题