Comments (4)
Comparing the types before setting the values is not so easy. The dictionary from the json string will contain NSString, NSNumber, arrays and dictionary values. The object itself will have Swift.String, Swift,Int, Swift.Int64, Swift.Double, various enums and other values. The types are almost always different.
Besides that the check should also not break the workarounds that are in WorkaroundsTests.swift.
I would rather turn it around and also set the value when you are trying to put a number into a string. That would mean I only have to add 1 exception when setting the value. You have a property that has the same name in the json. the chance is big you want that json value in your object anyway.
from evreflection.
I have added the exception where a NSNumber can be set to a string property in the latest release 2.4.6. I would like to know what your idea is regarding that workaround. What objections could you thing of for solving it this way.
As an alternative I could also skip setting the value in the 2 specific situations (string to number and number to string) But then what happens when you have a string and someone forgot to set the quotes around a number in the json. I think I still favorite setting the value over not setting the value.
from evreflection.
Your solution is ok. The only objection i see right now is that it can cause confusion why this is possible.
from evreflection.
Thanks, then I will leave the fix as it is now.
from evreflection.
Related Issues (20)
- parse json to Dictionary and nested Dictionaries HOT 2
- EVReflaction does not process booleans HOT 2
- Type 'EVObject' does not conform to protocol 'EVReflectable' HOT 3
- EVReflection json mapper to class online HOT 1
- RealmSwiftObject empty HOT 3
- Crash in EVReflection 5.10.0 and IOS13 HOT 2
- Canβt install pod HOT 3
- When can we expect Alamofire compatible version 5.0.0-rc.3? HOT 6
- Conversion Realm objects to dictionary: property mapping in nested arrays
- Unusable With Default Settings in XCode 11.4.1 HOT 10
- Cant Parse Dynamic object like array string and dictonary HOT 16
- Base object validator not called
- Override Hashable. HOT 1
- Insecure Storage: Lacking Data Protection HOT 1
- Is it possible to work with URL session ? HOT 1
- Crash in NSArray HOT 7
- XML parsing doesn't work
- Errors on install pod: Generic type 'DataResponse' specialized with too few type parameters (got 1, but expected 2)
- The SPM cannot be used HOT 1
- Doesn't support Struct type? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from evreflection.