分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 运营维护

Paste JSON as Code ? quicktype 软件的使用

发布时间:2023-09-06 02:22责任编辑:林大明关键词:暂无标签

1、软件图标认知

  • 该软件为json字符串与对象之间相互转户的自动化软件。
  • 下载地址

2、打开软件

  • 配置基本设置

3、生成.h文件

  • 选择生成.h文件
  • 拷贝代码到你管理该对象json文件的.h文件下

4、生成.m文件

  • 选择生成.m文件
  • 拷贝代码到你管理该对象json文件的.m实现文件下

5、代码实际测试

  • 5.1 获取json字符串

    • 这里json字符串存储在文件中
  • 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 实际效果

Paste JSON as Code ? quicktype 软件的使用

原文地址:https://www.cnblogs.com/CH520/p/9969890.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved