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

前端 未结 4 1065
不思量自难忘°
不思量自难忘° 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:48

    From Swift4 we can use JSONEncoder itself to convert Object model to Json String.

    For that we just needs to extends the Object with Codable if the json keys are standard.

    Reference :

    • https://developer.apple.com/documentation/foundation/jsonencoder
    • https://developer.apple.com/documentation/foundation/archives_and_serialization/using_json_with_custom_types

提交回复
热议问题