All Projects → Chasel-Shao → Csmodel

Chasel-Shao / Csmodel

Licence: mit
CSModel is a concise and efficient model framework for iOS/OSX, and provides nested Model to compare values and copy values.

Projects that are alternatives of or similar to Csmodel

Mjextension
A fast, convenient and nonintrusive conversion framework between JSON and model. Your model class doesn't need to extend any base class. You don't need to modify any model file.
Stars: ✭ 8,458 (+4305.21%)
Mutual labels:  dictionary, array, json, model
Kakajson
Fast conversion between JSON and model in Swift.
Stars: ✭ 867 (+351.56%)
Mutual labels:  dictionary, array, json, model
Mlib
Library of generic and type safe containers in pure C language (C99 or C11) for a wide collection of container (comparable to the C++ STL).
Stars: ✭ 321 (+67.19%)
Mutual labels:  dictionary, array, json
Core
Elm's core libraries
Stars: ✭ 2,634 (+1271.88%)
Mutual labels:  dictionary, array, json
Swiftai
SwiftAI, write Swift code smart. SwiftAI can generate Model class from JSON now. Codable and HandyJSON is supported. More features will be add.
Stars: ✭ 470 (+144.79%)
Mutual labels:  json, model
Jsonconverter
JSONConverter is a desktop application for Mac OS X which enables you to covert JSON objects preview pretty rich JOSN and model classes
Stars: ✭ 402 (+109.38%)
Mutual labels:  json, model
Awesome chinese medical nlp
中文医学NLP公开资源整理:术语集/语料库/词向量/预训练模型/知识图谱/命名实体识别/QA/信息抽取/模型/论文/etc
Stars: ✭ 623 (+224.48%)
Mutual labels:  dictionary, model
Whc datamodelfactory
Mac上iOS开发辅助工具,快速把json/xml数据转换生成对应模型类属性,省去麻烦手动创建,提高开发效率。Mac iOS development aid, quickly put the json/XML data transformation generates the corresponding model class attribute, save trouble created manually, improve the development efficiency.
Stars: ✭ 1,118 (+482.29%)
Mutual labels:  json, model
Python Benedict
dict subclass with keylist/keypath support, I/O shortcuts (base64, csv, json, pickle, plist, query-string, toml, xml, yaml) and many utilities. 📘
Stars: ✭ 204 (+6.25%)
Mutual labels:  dictionary, json
Leetheme
优雅的主题管理库- 一行代码完成多样式切换
Stars: ✭ 762 (+296.88%)
Mutual labels:  json, model
Hibernate Types
The Hibernate Types library gives you extra types that are not supported by the Hibernate ORM core.
Stars: ✭ 1,122 (+484.38%)
Mutual labels:  array, json
Moyamapper
快速解析模型工具,支持RxSwift。同时支持缓存功能 【相关手册 https://MoyaMapper.github.io 】
Stars: ✭ 115 (-40.1%)
Mutual labels:  json, model
ZXDataHandle
简单易用的数据转换和存储框架,支持一行代码将模型、模型数组、Json字符串、字典互转;支持模型映射到sqlite3数据库,无需书写sql
Stars: ✭ 13 (-93.23%)
Mutual labels:  dictionary, model
Coolie
Coolie(苦力) helps you to create models (& their constructors) from a JSON file.
Stars: ✭ 508 (+164.58%)
Mutual labels:  json, model
Dyno
Package dyno is a utility to work with dynamic objects at ease.
Stars: ✭ 81 (-57.81%)
Mutual labels:  dictionary, array
Framework
Strongly-typed JavaScript object with support for validation and error handling.
Stars: ✭ 136 (-29.17%)
Mutual labels:  json, model
Vscode Data Preview
Data Preview 🈸 extension for importing 📤 viewing 🔎 slicing 🔪 dicing 🎲 charting 📊 & exporting 📥 large JSON array/config, YAML, Apache Arrow, Avro, Parquet & Excel data files
Stars: ✭ 245 (+27.6%)
Mutual labels:  array, json
Swift Utils
A collection of handy swift utils
Stars: ✭ 253 (+31.77%)
Mutual labels:  array, json
Ladybug
A powerful model framework for Swift 4
Stars: ✭ 147 (-23.44%)
Mutual labels:  json, model
Crystdb
CrystDB is a thread-safe and convenient Object Relational Mapping database that based on SQLite.
Stars: ✭ 146 (-23.96%)
Mutual labels:  model, runtime

CSModel

Language License MIT  CocoaPods 

📖 English Documentation | 📖 中文文档

Introduce

CSModel is a concise and efficient model framework for iOS/OSX, and provides nested Model to compare values and copy values.

Features

  • Lightweight: Easily and simpily to use,less source files
  • Noninvasive: No need to inherit other class
  • Type Safe: Checks every type of the object, and deal with the null in json
  • High Performance: Parses the json very fast and supported the nested model
  • Compare : Supported the value compare which can be multinest model
  • Copy : Provides the nested model copy from another model

Performance

The time cost of disposing 10000 times GithubUser objects (iPhone 6s).

Benchmark result

Getting Started

The conversion between JSON, Model and String

// JSON:
{
    "uid":8082,
    "name":"Amy",
    "age":23
}

// Model:
@interface Person : NSObject
@property (nonatomic, assign) UInt64 uid;
@property (nonatomic, copy) NSString *name;
@property (nonatomic, assign) NSInteger age;
@end
@implementation Person
@end
	
// 1. Converting the JSON to an Model:
Person *p = [Person cs_modelWithJSONObject:json];

// 2. Converting the String to an Model:
 Person *np = [Person cs_modelWithJSONString:jsonStr];
	
// 3. Converting the Model to an JSON:
id json = [p cs_JSONObject];

// 4. Converting the Model to an NSString:
NSString *jsonStr =  [p cs_JSONString];

// 5. Converting the JSON Array to an Model Array:
NSArray *array = [Person cs_modelArrayWithJSONObject:jsonArray];

How to use Protocol

// 1. If a value of key in the json is an array,The json array will be
// conveted to model array by implementing this method.
+ (NSDictionary<NSString *,NSString *> *)CSModelKeyWithPropertyMapping
    return @{@"user_id":@"userId"};
}

// 2. If a value of key is a JSON object , implement this method to convert
// the JSON object to a model's properites.
+ (NSDictionary<NSString *,Class> *)CSModelArrayWithModelMapping{
    return @{@"child":[Person class]};
}

// 3. The mapping of model property and json key
+ (NSDictionary<NSString *,Class> *)CSModelDictionaryKeyWithModelMapping{
    return @{@"child":[Person class]};
}

The comparing and copying method

// Model 
@interface Teacher : NSObject
@property (nonatomic, copy) NSString *name;
@property (nonatomic, assign) NSInteger age;
@property (nonatomic, copy) NSString *books;
@end
@implementation Teacher
@end

// 1. Comparing the value of two models, supported the nested Model:
BOOL isSame = [p cs_isEqualToValue:p2];

// 2. Copying the value of an model, supported the nested Model:
Person *p2 = [p cs_modelCopy];

// 3. Copying from the different model:
Teacher *teacher1 = [Teacher cs_modelCopyFromModel:p];

The description method

// Implementing the method in the `.m file` of the Model
- (NSString *)description{
    return [self cs_description];
}

The coding method

// Implementing the following method in the `.m file` of the Model
- (void)encodeWithCoder:(NSCoder *)aCoder{
    [self cs_encode:aCoder];
}
- (instancetype)initWithCoder:(NSCoder *)aDecoder{
    return [self cs_decoder:aDecoder];
}

Installation

Installation with CocoaPods

  1. Specify the pod 'CSModel' to the Podfile
  2. Then, run pod install or pod update
  3. Import the header files <CSModel/CSModel.h>

Manual installation

  1. Download the CSModel source files
  2. Import the CSModel.h and related source files

Author

License

CSModel is released under the MIT license. See LICENSE for details.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].