Is SwiftyJson capable of converting a custom swift class to a json string?

前端 未结 4 1059
不思量自难忘°
不思量自难忘° 2021-02-15 08:11

Given below is my custom swift class. My Question is how to convert an object of this class to a json string using SwiftyJson?

class Equipment{

    var UniqueI         


        
4条回答
  •  礼貌的吻别
    2021-02-15 08:43

    In Swift 4, there's now the Codable framework that's baked in. From my research this is the best option for those who can upgrade to the latest version of the language.

    If the property names are identical it's just a few lines to call up a json decoder, and if they're different you just have to write a small switch statement to map them.

    I'm sure in the coming months a library will pop up to take care of standard mapping situations but other than that things are looking pretty good out of the box.

    check it here: http://benscheirman.com/2017/06/ultimate-guide-to-json-parsing-with-swift-4/

提交回复
热议问题