博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Paste JSON as Code • quicktype 软件的使用
阅读量:7077 次
发布时间:2019-06-28

本文共 1492 字,大约阅读时间需要 4 分钟。

1、软件图标认知

  • 该软件为json字符串与对象之间相互转户的自动化软件。
  • 1213778-20181116153747106-1864510389.png

2、打开软件

  • 配置基本设置
    1213778-20181116155352748-646761873.png

3、生成.h文件

  • 选择生成.h文件
  • 拷贝代码到你管理该对象json文件的.h文件下
    1213778-20181116155542827-1272389721.png
    1213778-20181116155852441-1088949300.png

4、生成.m文件

  • 选择生成.m文件
  • 拷贝代码到你管理该对象json文件的.m实现文件下
    1213778-20181116155638686-695574685.png
    1213778-20181116155857671-424384242.png

5、代码实际测试

  • 5.1 获取json字符串

    • 这里json字符串存储在文件中
      1213778-20181116160429218-555762109.png
  • 5.2 操作代码

    /************ 读取桌面文件测试Json *****************************/- (void)readFilesToTestJson {    NSString *thepath = @"/Users/lelight/Desktop/jsonFile.txt";    if ([[NSFileManager defaultManager] fileExistsAtPath:thepath]) {        NSData *data = [[NSData alloc] initWithContentsOfFile:thepath];        NSError *error = nil;        CH_GetAquariumLampCustomDataItemArray *dataItemArray = CH_GetAquariumLampCustomDataItemArrayFromData(data, &error);        CHLog(@"json转对象 %@", dataItemArray);        for (CH_GetAquariumLampCustomDataItemArrayElement *dataItem in dataItemArray) {            CHLog(@"json对象 week %@", dataItem.week);        }        NSString *jsonString = CH_GetAquariumLampCustomDataItemArrayToJSON(dataItemArray, NSUTF8StringEncoding, &error);        CHLog(@"对象转json %@", jsonString);        CH_GetAquariumLampCustomDataItemArray *dataItemArrayB = CH_GetAquariumLampCustomDataItemArrayFromJSON(jsonString, NSUTF8StringEncoding, &error);        CHLog(@"json转对象 %@", dataItemArrayB);        NSData *jsonStringB = CH_GetAquariumLampCustomDataItemArrayToData(dataItemArrayB, &error);        CHLog(@"对象转json %@", jsonStringB);        [CHTCPCustomDataItem shareInstance].dataItemArray = dataItemArray;    }    else {        NSLog(@"文件不存在");    }}
  • 5.3 实际效果

    1213778-20181116160646991-686374595.png

转载于:https://www.cnblogs.com/CH520/p/9969890.html

你可能感兴趣的文章
解决ajax 跨域请求问题
查看>>
Linux下进程描述(1)—进程控制块【转】
查看>>
【Gamma】Scrum Meeting 4
查看>>
设计模式:适配器模式(Adapter)
查看>>
Linux环境搭建及命令
查看>>
【人工智能】 火爆的机器学习和人工智能,为何在金融业四处碰壁?
查看>>
kafka术语
查看>>
mitmproxy
查看>>
kafa单机版环境搭建
查看>>
kettle报错收集
查看>>
Json
查看>>
分布式隐式事务
查看>>
python中的str.strip()的用法
查看>>
递归函数
查看>>
Shell 输入/输出重定向
查看>>
go package包的使用
查看>>
MongoDB学习笔记Day3
查看>>
spark学习1(hadoop集群搭建)
查看>>
ABP源码分析三十二:ABP.SignalR
查看>>
bootstrap 不兼容ie8 的问题
查看>>