Unity Json解析IPA
今天看到一个unity 自带的解析json的IPA,感觉比litjson好用很多,废话不多,上代码
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
using System.IO; [Serializable]
public class MyClass
{
public int level;
public float timeElapsed;
public string playerName;
}
public class Srealizable : MonoBehaviour {
string json;
string path;
private void Awake()
{
path = Application.streamingAssetsPath + "/myclas.txt";
}
// Use this for initialization
void Start () { Test1();}
public void Test1()
{
MyClass myObject = new MyClass();
myObject.level = ;
myObject.timeElapsed = 47.5f;
myObject.playerName = "Dr Charles Francis";
json = JsonUtility.ToJson(myObject);
Debug.LogError(json);
// DesTets();
WritOBJ();
} public void DesTets()
{
MyClass Obj = JsonUtility.FromJson<MyClass>(json);
Debug.LogError(Obj.level);
} void WritOBJ()
{
StreamWriter streamWriter = new StreamWriter(path,true);
// byte[] data = System.Text.Encoding.Unicode.GetBytes(json);
streamWriter.Write(json);
streamWriter.Close();
ReadOBJ();
}
void ReadOBJ()
{
StreamReader streamReader = new StreamReader(path);
string str= streamReader.ReadToEnd();
streamReader.Close();
MyClass obj = JsonUtility.FromJson<MyClass>(str);
Debug.LogError(obj.level + " " + obj.playerName + " " + obj.timeElapsed);
}
}
Unity Json解析IPA的更多相关文章
- unity json解析IPA后续
以前说到的,有很大的限制,只能解析简单的类,如果复杂的就会有问题,从老外哪里看到一片博客,是将类中的list 等复杂对象序列化, using UnityEngine; using System.C ...
- Unity的Json解析<二>–写Json文件
本文章由cartzhang编写,转载请注明出处. 所有权利保留. 文章链接:http://blog.csdn.net/cartzhang/article/details/50378805 作者:car ...
- Unity的Json解析<一>--读取Json文件
本文章由cartzhang编写,转载请注明出处. 所有权利保留. 文章链接:http://blog.csdn.net/cartzhang/article/details/50373558 作者:car ...
- iOS开发之Swift 4 JSON 解析指南
Apple 终于在 Swift 4 的 Foundation 的模块中添加了对 JSON 解析的原生支持. 虽然已经有很多第三方类库实现了 JSON 解析,但是能够看到这样一个功能强大.易于使用的官方 ...
- Swift Json解析与model互转
Json的解码与编码操作,这里使用swift自带的类JSONDecoder 和 JSONEncoder 1.基础处理 如果你的 JSON 数据结构和你使用的 Model 对象结构一致的话,那么解析过程 ...
- Android okHttp网络请求之Json解析
前言: 前面两篇文章介绍了基于okHttp的post.get请求,以及文件的上传下载,今天主要介绍一下如何和Json解析一起使用?如何才能提高开发效率? okHttp相关文章地址: Android o ...
- Json解析工具的选择
前言 前段时间@寒江不钓同学针对国内Top500和Google Play Top200 Android应用做了全面的分析(具体分析报告见文末的参考资料),其中有涉及到对主流应用使用json框架Gson ...
- iOS json 解析遇到error: Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed.
Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed. (Cocoa error 38 ...
- Android之JSON解析
做个Android网络编程的同学一定对于JSON解析一点都不陌生,因为现在我们通过手机向服务器请求资源,服务器给我们返回的数据资源一般都是以JSON格式返回,当然还有一些通过XML格式返回,相对JSO ...
随机推荐
- Android下Slidingmenu和actionbarsherlock的使用
1 http://blog.csdn.net/wangjinyu501/article/details/9331749 博客很多,推荐此教程,slidingmenu的demo可以演示 2 http: ...
- go http请求基础
1.请求方法: get post get 加请求参数,请求参数会加到url后面 post加请求参数,请求参数会放在body里面 请求方式:1.直接在url后面加参数 如:http://www.tes ...
- ubuntu打开终端多开标签的快捷键是ctrl+ shift+ T 对比ctrl+ alt+ T 另外窗口打开一个终端
ubuntu打开终端多开标签的快捷键是ctrl+ shift+ T 对比ctrl+ alt+ T 另外窗口打开一个终端
- python使用mysql数据库(虫师)
转自虫师 http://www.cnblogs.com/fnng/p/3565912.html 一,安装mysql 如果是windows 用户,mysql 的安装非常简单,直接下载安装文件,双击安装文 ...
- 通过pyenv进行多版本python管理
1.安装pyenv brew install pyenv 2.配置.zshrc文件 export PYENV_ROOT=/usr/local/var/pyenv if which pyenv > ...
- Docker-Compose 自动创建的网桥与局域网冲突解决方案
环境: 使用docker-compose.yml 部署应用,docker 默认的网络模式是bridge ,默认网段是172.17.0.1/16 ,不巧的是我们局域网也使用的172.22. xx 网段 ...
- Markdown GUI编辑器推荐 windows mac
windows 1. MarkdownPad 如果右边不能预览: LivePreview is not working - it displays an error message stating T ...
- linux 上安装apache 出现 configure: error: APR not found. Please read the documentation错误
今日编译apache时出错: #./configure --prefix……检查编辑环境时出现: checking for APR... noconfigure: error: APR not fou ...
- 如何简单的实现一个tab页title的动画效果
首先我们来看看实现的效果 tab上的title沉下去的效果 先来看看布局 <?xml version="1.0" encoding="utf-8"?> ...
- Live555 中的客户端动态库.so的调用方式之一 程序中调用
1. 打开动态链接库: #include <dlfcn.h> void *dlopen(const char *filename, int flag); 该函数返回操作 ...