//  ProductModel.h
// JSONModel
//
// Created by 张国锋 on 15/7/20.
// Copyright (c) 2015年 张国锋. All rights reserved.
// #import "JSONModel.h" @interface ProductModel : JSONModel @property (nonatomic,strong)NSString<Optional> * id1;
@property (nonatomic,strong)NSString<Optional> * name;
@property (nonatomic,strong)NSString<Optional> * price; @end // ProductModel.m
// JSONModel
//
// Created by 张国锋 on 15/7/20.
// Copyright (c) 2015年 张国锋. All rights reserved.
// #import "ProductModel.h" @implementation ProductModel
+(JSONKeyMapper *)keyMapper{
return [[JSONKeyMapper alloc] initWithDictionary:@{@"id":@"id1",@"sss":@"xxxxx"}];
}
@end
//  test1Model.h
// JSONModel
//
// Created by 张国锋 on 15/7/20.
// Copyright (c) 2015年 张国锋. All rights reserved.
// #import "JSONModel.h" @protocol test2Model
@end @interface test2Model : JSONModel
@property (nonatomic,strong)NSString<Optional> * id1;
@property (nonatomic,strong)NSString<Optional> * name;
@property (nonatomic,strong)NSString<Optional> * price;
@end @interface test1Model : JSONModel
@property (nonatomic,strong)NSString<Optional> * order_id;
@property (nonatomic,strong)NSString<Optional> * total_price;
@property (nonatomic,strong)NSArray<test2Model,Optional> * product;
@end // test1Model.m
// JSONModel
//
// Created by 张国锋 on 15/7/20.
// Copyright (c) 2015年 张国锋. All rights reserved.
// #import "test1Model.h" @implementation test2Model +(JSONKeyMapper *)keyMapper{
return [[JSONKeyMapper alloc] initWithDictionary:@{@"id":@"id1"}];
} @end @implementation test1Model @end
//  ViewController.h
// JSONModel
//
// Created by 张国锋 on 15/7/20.
// Copyright (c) 2015年 张国锋. All rights reserved.
// #import <UIKit/UIKit.h> @interface ViewController : UIViewController @end //
// ViewController.m
// JSONModel
//
// Created by 张国锋 on 15/7/20.
// Copyright (c) 2015年 张国锋. All rights reserved.
// #import "ViewController.h"
#import "test1Model.h"
@interface ViewController () @end @implementation ViewController - (void)viewDidLoad {
[super viewDidLoad];
NSDictionary *dic=[[NSDictionary alloc]init];
test1Model *model=[[test1Model alloc]initWithDictionary:dic error:nil];
/*
@property (nonatomic,strong)NSString<Optional> * order_id;
@property (nonatomic,strong)NSString<Optional> * total_price;
@property (nonatomic,strong)NSArray<test2Model,Optional> * product;
*/
// Do any additional setup after loading the view, typically from a nib.
} - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
} @end

JSONModel 简单例子的更多相关文章

  1. Hibernate4.2.4入门(一)——环境搭建和简单例子

    一.前言 发下牢骚,这段时间要做项目,又要学框架,搞得都没时间写笔记,但是觉得这知识学过还是要记录下.进入主题了 1.1.Hibernate简介 什么是Hibernate?Hibernate有什么用? ...

  2. AgileEAS.NET SOA 中间件平台.Net Socket通信框架-简单例子-实现简单的服务端客户端消息应答

    一.AgileEAS.NET SOA中间件Socket/Tcp框架介绍 在文章AgileEAS.NET SOA 中间件平台Socket/Tcp通信框架介绍一文之中我们对AgileEAS.NET SOA ...

  3. spring mvc(注解)上传文件的简单例子

    spring mvc(注解)上传文件的简单例子,这有几个需要注意的地方1.form的enctype=”multipart/form-data” 这个是上传文件必须的2.applicationConte ...

  4. ko 简单例子

    Knockout是在下面三个核心功能是建立起来的: 监控属性(Observables)和依赖跟踪(Dependency tracking) 声明式绑定(Declarative bindings) 模板 ...

  5. mysql定时任务简单例子

    mysql定时任务简单例子 ? 1 2 3 4 5 6 7 8 9     如果要每30秒执行以下语句:   [sql] update userinfo set endtime = now() WHE ...

  6. java socket编程开发简单例子 与 nio非阻塞通道

    基本socket编程 1.以下只是简单例子,没有用多线程处理,只能一发一收(由于scan.nextLine()线程会进入等待状态),使用时可以根据具体项目功能进行优化处理 2.以下代码使用了1.8新特 ...

  7. 一个简单例子:贫血模型or领域模型

    转:一个简单例子:贫血模型or领域模型 贫血模型 我们首先用贫血模型来实现.所谓贫血模型就是模型对象之间存在完整的关联(可能存在多余的关联),但是对象除了get和set方外外几乎就没有其它的方法,整个 ...

  8. [转] 3个学习Socket编程的简单例子:TCP Server/Client, Select

    以前都是采用ACE的编写网络应用,最近由于工作需要,需要直接只用socket接口编写CS的代码,重新学习这方面的知识,给出自己所用到的3个简单例子,都是拷贝别人的程序.如果你能完全理解这3个例子,估计 ...

  9. jsonp的简单例子

    jsonp的简单例子 index.html <!DOCTYPE html> <html> <head> <meta charset="UTF-8&q ...

随机推荐

  1. 「UVA11181」 Probability|Given(概率

    题意翻译 有n个人要去买东西,他们去买东西的概率为p[i]. 现在得知有r个人买了东西,在这种条件下,求每个人买东西的概率. 感谢@s_r_f 提供翻译 题目描述 PDF 输入输出格式 输入格式: 输 ...

  2. p1020导弹拦截

    传送门 P1020导弹拦截 题目描述 某国为了防御敌国的导弹袭击,发展出一种导弹拦截系统.但是这种导弹拦截系统有一个缺陷:虽然它的第一发炮弹能够到达任意的高度,但是以后每一发炮弹都不能高于前一发的高度 ...

  3. 【Lintcode】099.Reorder List

    题目: Given a singly linked list L: L0 → L1 → … → Ln-1 → Ln reorder it to: L0 → Ln → L1 → Ln-1 → L2 → ...

  4. python爬虫知识点总结(十)分析Ajax请求并抓取今日头条街拍美图

    一.流程框架

  5. C++ ADO连接

    #include "stdafx.h" #include <iostream> #include <iomanip> #include "wind ...

  6. Django简单快速实现PUT、DELETE方法

    使用django的小伙伴们应该都知道我们是无法开心的处理PUT跟DELETE的 $.ajax({ url: 'XXX', type: 'PUT', dataType: 'json', data: { ...

  7. JSP+JavaBean+Servlet工作原理实例…

    JSP+JavaBean+Servlet工作原理实例讲解 首先,JavaBean和Servlet虽都是Java程序,但是是完全不同的两个概念.引用mz3226960提出的MVC的概念,即M-model ...

  8. java之二叉树--未完待续

    参考http://how2j.cn/k/collection/collection-tree/476.html#nowhere 二叉树概念 二叉树由各种节点组成二叉树特点:每个节点都可以有左子节点,右 ...

  9. Jquery中的toggle()方法

    Jquery中的toggle()方法,有一次在看别人写的Jquery插件时,发现对toggle有如下使用 search.pagePrevious.toggle(data.pageNumber > ...

  10. 3. docker容器内信息获取、命令的执行、容器的导入和导出

    一.依附容器 依附操作attach通常用在由docker start或者docker restart启动的交互型容器中.由于docker start启动的交互型容器并没有具体终端可以依附,而容器本身是 ...