-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Be able to use own encoder and decoder. #1080
base: master
Are you sure you want to change the base?
Conversation
let encoder: JSONEncoder | ||
let decoder: JSONDecoder | ||
|
||
public init(decoder: JSONDecoder = .init(), encoder: JSONEncoder = .init()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why you decided to create an initializer for these properties?
I think this development is unnecessary to use encoder
and decoder
because these properties aren't use anywhere except functions.
On the other hand some cases we don't need to create encoder
or decoder
.
For example; if data
comes NULL in transformFromJSON (_ value:) -> Object?
function returns immediately from guard
statement and we don't create a decoder
.
transformToJSON (_ value: ) -> JSON?
has a same case, if value
comes NULL we don't create encoder
.
What do you think about this cases?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We want to set options for JSONDecoder and JSONEncoder.
For example, cannot set dataDecodingStrategy by current code.
Sources/CodableTransform.swift
Outdated
|
||
public init() {} | ||
let encoder: JSONEncoder | ||
let decoder: JSONDecoder |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe you should consider making those properties private. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
YES, serializers should be private.
No description provided.