Thursday, August 20, 2015

Updating to Mantle 2.0

I have been using Mantle for JSON serialisation for quite some time now. I loved it because it appeared to be a clean way to handle JSON objects. However somethings have changed in version 2.0. This is not an attempt to criticise the changes but an attempt to give a heads up before you update.

  • Value transformers have changed. Old transformers have been deprecated and new transformers have taken their place. Notice the compiler warnings once you update and compile.
  • Prior to version 2.0 any type errors in the JSON objects were handled by Mantle. Now the developer has to handle such mismatches. e.g. you need to add a transformer if you need to map a string property in the JSON object to an integer property in your class. Prior to version 2.0 transformers were required only if the transformation is not obvious. e.g. if you need to map a string property to a NSURL property (create a NSURL from a url string in the JSON).
  • Property map requires all the properties. Previous versions only required this only if the name of the property in your class is not the same as of the one in the JSON.
  • You cannot have properties that are not mapped to the JSON object

No comments: