Json字符串转模型类在线工具

[复制链接]
来自: 李兆祥 分类: iOS精品源码 上传时间: 2019-11-6 16:23:50
Tag:

项目介绍:

JsonToModelOnLine

github地址:https://github.com/SmileZXLee/JsonToModelOnLine

在线地址(点击直接访问):http://www.zxlee.cn/JsonToModelOnLine/index.html

主要功能

  • 支持语言:Java、PHP、Objective-C、Swift、C#、JavaScript

  • 支持下划线转驼峰或驼峰转下划线

  • 支持添加注释头

  • 支持任意层级的Json数据,自动过滤重复数据

图片描述

使用示例

示例Json数据(来源于聚合数据API文档)

{
    "error_code": 0,
    "success": true,
    "reason": "success",
    "result": {
        "collectCount": "4170000",
        "crawlTime": "2019-01-24 16:43:58",
        "ranks": [
            {
                "rankStr": "1-1",
                "title": "聚合工具 - 聚合数据",
                "url": "http:\/\/tool.chinaz.com\/",
                "xiongzhangId": "聚合数据"
            },
            {
                "rankStr": "1-2",
                "title": "聚合素材-分享综合设计素材的平台",
                "url": "http:\/\/sc.chinaz.com\/",
                "xiongzhangId": ""
            }
        ]
    }
}

转Java模型类

----- 共3条Model数据 -----
private String collectCount;
private String crawlTime;
private Object[] ranks;
----------------------------
private String rankStr;
private String title;
private String url;
private String xiongzhangId;
----------------------------
private int error_code;
private boolean success;
private String reason;
private Object result;
----------------------------
  • 驼峰转下划线

----- 共3条Model数据 -----
private String collect_count;
private String crawl_time;
private Object[] ranks;
----------------------------
private String rank_str;
private String title;
private String url;
private String xiongzhang_id;
----------------------------
private int error_code;
private boolean success;
private String reason;
private Object result;
----------------------------

转PHP模型类

----- 共3条Model数据 -----
public $collectCount;
public $crawlTime;
public $ranks;
----------------------------
public $rankStr;
public $title;
public $url;
public $xiongzhangId;
----------------------------
public $error_code;
public $success;
public $reason;
public $result;
----------------------------

转Objective-C模型类

----- 共3条Model数据 -----
@property (copy, nonatomic) NSString *collectCount;
@property (copy, nonatomic) NSString *crawlTime;
@property (strong, nonatomic) NSArray *ranks;
----------------------------
@property (copy, nonatomic) NSString *rankStr;
@property (copy, nonatomic) NSString *title;
@property (copy, nonatomic) NSString *url;
@property (copy, nonatomic) NSString *xiongzhangId;
----------------------------
@property (assign, nonatomic) int error_code;
@property (assign, nonatomic) BOOL success;
@property (copy, nonatomic) NSString *reason;
@property (strong, nonatomic) id result;
----------------------------

转Swift模型类

----- 共3条Model数据 -----
var collectCount :String?
var crawlTime :String?
var ranks :Array?
----------------------------
var rankStr :String?
var title :String?
var url :String?
var xiongzhangId :String?
----------------------------
var error_code :Int?
var success :Bool?
var reason :String?
var result :any?
----------------------------

转C#模型类

----- 共3条Model数据 -----
public string collectCount { get; set;};
public string crawlTime { get; set;};
public List <Object> ranks { get; set;};
----------------------------
public string rankStr { get; set;};
public string title { get; set;};
public string url { get; set;};
public string xiongzhangId { get; set;};
----------------------------
public int error_code { get; set;};
public boolean success { get; set;};
public string reason { get; set;};
public Object result { get; set;};
----------------------------

转JavaScript模型类

----- 共3条Model数据 -----
var collectCount;
var crawlTime;
var ranks;
----------------------------
var rankStr;
var title;
var url;
var xiongzhangId;
----------------------------
var error_code;
var success;
var reason;
var result;
----------------------------

相关源码推荐:

我来说两句
所有评论(8)
op568f 2019-11-6 18:33:23
支持,感谢,祝code4app越来越好~
回复
pp美景 2019-11-6 18:33:49
小弟学习了~支持,支持
回复
kengsir 2019-11-6 18:33:55
相当不错,感谢无私分享精神!
回复
天天bug 2019-11-6 18:35:35
学习...学习...
回复
应用安卓 2019-11-6 18:36:31
帮帮顶顶!!
回复
Wsdtg 2019-11-6 18:38:10
感谢分享,code4app有你更精彩
回复
去往巅峰 2019-11-30 13:37:53
很给力,Code4App有你更精彩!
回复
xiao66guo 2019-12-9 14:16:55
楼主用心了,内容非常精彩。
回复
提取码:  下载次数:0 状态:您未购买 售价:0(原价:10)金钱 下载权限:初级码农 
306 0 0
联系我们
首页/微信公众账号投稿

帖子代码编辑/版权问题

QQ:435399051,742864542

如何获得代码达人称号?

代码贡献英雄榜
用户名 下载数
通过邮件订阅最新 Code4App 信息
上一条 /4 下一条

广告投放| 广东互联网违法和不良信息举报中心|中国互联网举报中心|Github|申请友链|手机版|Code4App ( 粤ICP备15117877号-1 )