The quickest and easiest transition between JSON and model iOS framework: mjextension

Source: Internet
Author: User

Read Catalogue

    • What can I do?
    • The differences between Mjextension and Jsonmodel, mantle and other frameworks
    • How to use Mjextension
    • The simplest dictionary-to-model

Mjextension is the fastest and most convenient transition between JSON and the model iOS framework.

What can I do?
    • Mjextension is a set of ultra-lightweight frameworks that convert between dictionaries and models
    • Mjextension functions that can be done
      • Dictionary (JSON)--model
      • Model--Dictionary (JSON)
      • Dictionary array (JSON array)--model array
      • Model Array and dictionary array (JSON array)
    • Detailed usage mainly refer to the functions in MAIN.M and nsobject+mjkeyvalue.h
Back to the top mjextension and Jsonmodel, mantle and other framework differences
    • Conversion rate:
      • A recent test showed that: Mjextension>jsonmodel>mantle
      • Developers can also test their own
    • Specific usage:
      • Jsonmodel: Requires all model classes to inherit from the Jsonmodel base class
      • Mantle: Requires all model classes to inherit from the Mtmodel base class
      • Mjextension: No need for your model class to inherit any special base class, no pollution, no intrusion
Back to top how to use Mjextension
  • Cocoapods import: Pod ' mjextension '
  • Manual import:
    • Drag all the source code in the Mjextensionexample/mjextensionexample/mjextension folder into the project
    • Import Primary header file: #import "MJExtension.h"?
      12345678 MJExtension.hMJConst.h               MJConst.mMJFoundation.h          MJFoundation.mMJIvar.h                MJIvar.mMJType.h                MJType.mNSObject+MJCoding.h     NSObject+MJCoding.mNSObject+MJIvar.h       NSObject+MJIvar.mNSObject+MJKeyValue.h   NSObject+MJKeyValue.m
Go back to the top of the simplest dictionary to model?
1234567891011121314151617181920212223242526272829 typedef enum {    SexMale,    SexFemale} Sex;@interface User : NSObject@property (copy, nonatomic) NSString *name;@property (copy, nonatomic) NSString *icon;@property (assign, nonatomic) int age;@property (assign, nonatomic) double height;@property (strong, nonatomic) NSNumber *money;@property (assign, nonatomic) Sex sex;@endNSDictionary *dict = @{               @"name" : @"Jack",               @"icon" : @"lufy.png",               @"age" : @20,               @"height" : @"1.55",               @"money" : @100.9,               @"sex" : @(SexFemale)            };// 将字典转为User模型User *user = [User objectWithKeyValues:dict]; NSLog(@"name=%@, icon=%@, age=%d, height=%@, money=%@, sex=%d",    user.name, user.icon, user.age, user.height, user.money, user.sex);// name=Jack, icon=lufy.png, age=20, height=1.550000, money=100.9, sex=1
Core code
    • [User Objectwithkeyvalues:dict]

Project home:http://www.open-open.com/lib/view/home/1426233573592

The quickest and easiest transition between JSON and model iOS framework: mjextension

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.