Skip to content

wanewang/JSON2Realm

Repository files navigation

JSON2Realm

Integrate with JSON Parser to Realm Object

Language: Swift Language: Swift Build Status

Purpose

My project need a JSON parser which can integrate with Realm class(easily) and back to JSON object with customizable transformer (basically nil to NSNull) I tried some of the high star JSON parser and write down my thought about them. I prefer the Genome1.0 but recently it upgraded to 2.0 with some syntax changed

Basic Class

class BasicClass: Object {
  dynamic var name: String = ""
  dynamic var birthday: String = ""
  dynamic var age: Int = 0
}

class BasicOptionalClass: Object {
  var distance = RealmOptional<Int>()
  dynamic var note: String? = nil
  dynamic var value: Int = 0
}

GenomeObject1.0

GenomeObject2.0

  1. Need to use final on class since it use Self on protocol extension
  2. Genome will throw error while encounter parsing issue
  3. Have method for transform object to JSON
  4. Customizable JSON value representation
  5. since Genome return Json Object, you have to use .foundationDictionary or .anyValue to get Dictionary or AnyObject

ObjectMapperObject

link: ObjectMapper+Realm

  1. ObjectMapper will set to default value while encounter parsing issue
  2. Have method for transform object to JSON but need to execute inside Realm write transaction
  3. Customizable JSON value representation (ex. return NSNull value)

ArgoOld(withou Curry)

ArgoObject

  1. Have to include Curry or you will see brackets hell
  2. Argo will return nil object while encounter parsing issue
  3. Can not transform object to JSON

GlossObject

  1. Need to use final on class since it use Self on protocol extension
  2. Gloss have the ability to customize action while encounter parsing issue(return nil for this example)
  3. Have method for transform object to JSON

UnboxObject

  1. Unbox can either return nil or throw error while encounter parsing issue
  2. Can not transform object to JSON

FreddyObject

  1. Freddy will throw error while encounter parsing issue
  2. Provided nested json object parser
  3. Can not init with Dictionary, I use NSJSONSerialization transform AnyObject, Disctionary to NSData
  4. Not yet have inline transformer, issue
  5. Have method for transform object to JSON

Next

  1. Nested Json Transformer

About

Integrate with JSON Parser to Realm Object

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published