Hi.
I use Gson for mapping objects in Java. With Gson I can define constants values (final) for a given class, but I think it is not possible to do it using ObjectMapper, isn’t it?
I mean, can I define constant properties with “let” using ObjectMapper?
I think the fact it could not be possible is something to do with the language Swift itself, some kind of limitation, but I do not know exactly why.
But it is really frustrating to not be able to prevent mutability in my system in classes mapped with ObjectMapper, which are the majority!
And by the way, thank you for this great library ;)
For the sake of simplicity I have chosen to not support immutable types in ObjectMapper for the time being. I have some experimental code in the project that supports it, however it is not fully tested and I am not recommending it's use at the moment. If you need immutable types there are other projects such as Argo which support it.
I'd like to :+1: support for let
properties. However there are a couple of workarounds:
var
declarations with private (set)
. struct
) instead of reference semantics (class
), and assign it to a let
property. note that this has some side effects that may or may not be desirable. @frankus I just created an issue for this #383
Most helpful comment
I'd like to :+1: support for
let
properties. However there are a couple of workarounds:var
declarations withprivate (set)
.struct
) instead of reference semantics (class
), and assign it to alet
property. note that this has some side effects that may or may not be desirable.