JSON是一种轻量级的数据交换格式。它基于ECMAScript的一个子集,使用完全独立于编程语言的文本格式来存储和表示数据。简单和清晰的层次结构使JSON成为一种理想的数据交换语言。便于人的读写,也便于机器解析生成,能够有效提高网络传输的效率。下面是转换后的程序代码:usingSystem.Collections;usingSystem.Collections.Generic;usingSystem.IO;usingSystem.Text;usingLitJson;usingUnityEngine;usingExcel;usingExcel.Core;usingOfficeOpenXml.Style;usingOfficeOpenXml;///>(jsondata);//固定格式Debug.LogError(node.Count);}voidReadTextToJson(){DataCenterdc=newDataCenter();//实例化dc,稍后使用它的List//读取文件固定格式using(StreamReaderreader=newStreamReader(_txtPath,Encoding.UTF8)){stringtmpStr=string.空的;while(!string.IsNullOrEmpty(tmpStr=reader.ReadLine())){string[]infos=tmpStr.Split('_');DataNode_node=newDataNode();//实例化调用其属性_node.CopyName=infos[0];//赋值读取内容_node.CopyPosition=infos[1];_node.CopyRotation=信息[2];dc.List.Add(_node);//将内容添加到列表中}}//读取数据后,开始写入json传过来的List<>字符串。jsonData=JsonMapper.ToJson(dc.List);File.WriteAllText(_jsonPath,jsonData);}privatevoidWriteExcel(stringpath){DataCenterdc=newDataCenter();//实例化dc,稍后使用它的List//读取固定格式using(StreamReaderreader=newStreamReader(_txtPath,Encoding.UTF8)){stringtmpStr=字符串.空;while(!string.IsNullOrEmpty(tmpStr=reader.ReadLine())){string[]infos=tmpStr.Split('_');DataNode_node=newDataNode();//实例化调用其属性_node.CopyName=infos[0];//赋值读取内容_node.CopyPosition=infos[1];_node.CopyRotation=信息[2];dc.List.Add(_node);//添加内容到列表}}Debug.LogError(dc.List.Count);FileInfoexcelInfo=newFileInfo(路径);如果(excelInfo.Exists)新文件信息(路径);}//开始使用Excelusing(ExcelPackagepackage=newExcelPackage(excelInfo)){ExcelWorksheetsheet=package.Workbook.Worksheets.Add("TestInfo");//添加了一个工作表sheet.Cells[1,1].Value="CopyName";sheet.Cells[1,2].Value="CopyPosition";sheet.Cells[1,3].Value="CopyRotation";对于(inti=0;i
