Latest 1.0.6
Homepage https://github.com/maxfong/MFSJSONEntity
License MIT
Platforms ios 6.0
Authors

JSON和Object互转是App开发中最常用的功能之一;

MFSJSONEntity的特点:

  • NSObject的类别;
  • 比较轻量;
  • 转换功能全;

实体对象属性类型支持:

  • NSString
  • NSArray
  • NSDictionary
  • NSNull
  • 值基本类型

安装

编译静态Framework

git clone https://github.com/maxfong/MFSJSONEntity.git

选择 lipoFramework Target 编译即可

引用framework

#import <MFSJSONEntity/MFSJSONEntity.h>
使用framework需Other Linker Flags添加-ObjC;

CocoaPods

编辑Pofile
pod 'MFSJSONEntity', '1.0.6'
安装
pod install

更多关于CocoaPods.

使用

Object -> Dictionary(当前类属性键值对)

Person *person = Person.new;
person.name = @"max";
person.age = 99;
NSDictionary *personDict = [person propertyDictionary];
NSLog(@"Person:%@", personDict);

Dictionary -> Object(支持多层嵌套)

NSString *JSONString = @"{"name":"max","age":98}";
NSData *JSONData = [JSONString dataUsingEncoding:NSUTF8StringEncoding];
NSDictionary *dictionary = [NSJSONSerialization JSONObjectWithData:JSONData options:NSJSONReadingAllowFragments error:nil];
Person *obj = [Person objectWithDictionary:dictionary];
NSLog(@"person:%@, name:%@, age:%ld", obj, obj.name, obj.age);

属性列表(可自定义父类)

NSArray *propertys = [Person propertyNames];
NSLog(@"Person propertys:%@", propertys);

其他

如果您发现任何问题或有啥建议,发个issues,谢谢;

License

MFSJSONEntity is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "MFSJSONEntity",
    "version": "1.0.6",
    "summary": "JSON To Entity Object & Object To JSON String",
    "description": "                   JSONu8f6cObjectu662fu5f00u53d1u4e2du6700u5e38u7528u7684u529fu80fdu4e4bu4e00;nn                   MFSJSONEntityu7684u7279u70b9u662fu5b83u53eau662fNSObjectu7684u7c7bu522buff0cu6bd4u8f83u8f7bu91cfuff0cu6dfbu52a0u5b83u5c31u80fdu4f7fu7528JSONu540cObjectu76f8u4e92u8f6cu6362u7684u529fu80fduff1b n                   u5b9eu4f53u5bf9u8c61u5c5eu6027u7c7bu578bu652fu6301uff1aNSStringu3001NSArrayu3001NSDictionaryu3001NSNullu548cu503cu57fau672cu7c7bu578buff1b n                   u4f7fu7528frameworku9700Other Linker Flagsu6dfbu52a0-ObjCuff1bn",
    "homepage": "https://github.com/maxfong/MFSJSONEntity",
    "license": "MIT",
    "authors": {
        "maxfong": "[email protected]"
    },
    "platforms": {
        "ios": "6.0"
    },
    "source": {
        "git": "https://github.com/maxfong/MFSJSONEntity.git",
        "tag": "1.0.6"
    },
    "source_files": [
        "MFSJSONEntity",
        "MFSJSONEntity/*.{h,m}"
    ],
    "exclude_files": "MFSJSONEntity/MFSJSONEntity Tests"
}

Pin It on Pinterest

Share This