-
Notifications
You must be signed in to change notification settings - Fork 45
Some odd condition after issue #12 #13
Comments
Hello @shinrenpan , The behaviour that you have described is exactly what I have designed.
Therefore, could you explain what are you solving in your gist? If you tell me what are you trying to achieve I can explain you how you should use Motis to handle it. Thanks, Joan |
Hi @vilanovi In condition 1, the User class has property name as same as JSON key I thought the Motis will In my gist line 441, before the Motis set value for key, I implement that - However, the developer who uses the Motis can override But I think less code is better for developer who uses the Motis :) |
Hello @shinrenpan, As you say, If your are receiving JSON that contains key-value pairs that your model objects are not handling you must perform one of the following two approaches in order to use Motis:
My personal suggestion is to do approach 1). You will be sure that you are redirecting the JSON key-value pairs to your desired properties. Also, because Motis is filtering your JSON containers, you will be sure that no "undesired JSON key-values pairs" are being set to any of your object properties or superclass object properties. Currently, I really think that by using Motis to perform the JSON object mapping you are writing almost no code, and for those specific cases (as it happens to you) you only need to add a few lines more. Please, do not hesitate to contact me again if you have any other problem. Thanks, Joan |
Example:
source JSON
User.h
Condition 1
Did't implement both mts_shouldSetUndefinedKeys and implement +mts_mapping
Condition 2
Only implement mts_shouldSetUndefinedKeys
Condition 3
Implment both implement + mts_shouldSetUndefinedKeys, implement +mts_mapping
I have no time to review all code but I have fixed issue in gist quickly, you can compare it.
It will works for Condition 1, 2, 3.
The text was updated successfully, but these errors were encountered: