今天看到一个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的更多相关文章

  1. unity json解析IPA后续

    以前说到的,有很大的限制,只能解析简单的类,如果复杂的就会有问题,从老外哪里看到一片博客,是将类中的list   等复杂对象序列化, using UnityEngine; using System.C ...

  2. Unity的Json解析<二>–写Json文件

    本文章由cartzhang编写,转载请注明出处. 所有权利保留. 文章链接:http://blog.csdn.net/cartzhang/article/details/50378805 作者:car ...

  3. Unity的Json解析<一>--读取Json文件

    本文章由cartzhang编写,转载请注明出处. 所有权利保留. 文章链接:http://blog.csdn.net/cartzhang/article/details/50373558 作者:car ...

  4. iOS开发之Swift 4 JSON 解析指南

    Apple 终于在 Swift 4 的 Foundation 的模块中添加了对 JSON 解析的原生支持. 虽然已经有很多第三方类库实现了 JSON 解析,但是能够看到这样一个功能强大.易于使用的官方 ...

  5. Swift Json解析与model互转

    Json的解码与编码操作,这里使用swift自带的类JSONDecoder 和 JSONEncoder 1.基础处理 如果你的 JSON 数据结构和你使用的 Model 对象结构一致的话,那么解析过程 ...

  6. Android okHttp网络请求之Json解析

    前言: 前面两篇文章介绍了基于okHttp的post.get请求,以及文件的上传下载,今天主要介绍一下如何和Json解析一起使用?如何才能提高开发效率? okHttp相关文章地址: Android o ...

  7. Json解析工具的选择

    前言 前段时间@寒江不钓同学针对国内Top500和Google Play Top200 Android应用做了全面的分析(具体分析报告见文末的参考资料),其中有涉及到对主流应用使用json框架Gson ...

  8. 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 ...

  9. Android之JSON解析

    做个Android网络编程的同学一定对于JSON解析一点都不陌生,因为现在我们通过手机向服务器请求资源,服务器给我们返回的数据资源一般都是以JSON格式返回,当然还有一些通过XML格式返回,相对JSO ...

随机推荐

  1. MySQL加入服务、设置password、改动password

    修正:加入MySQL服务时,能够不带版本.也就说以下的全部MySQL57能够直接写成MySQL!希望大家注意. MySQL安装好之后,往往还须要再做一些设置! 1.加入MySQL服务: 输入命令cmd ...

  2. Laravel5.4使用Memcached缓存

    修改默认的缓存驱动 Laravel默认的缓存驱动是file,想要切换为Memcached需要修改.env文件.把CACHE_DRIVER=file改为CACHE_DRIVER=memcached,改好 ...

  3. Atitit.程序包装exe启动器 打包 发布 设计 -生成exe java

    Atitit.程序包装exe启动器 打包 发布 设计 -生成exe java 1. 要实现的功能1 2. ahk是个好东东..能启动了...1 3. exe4j   vs  nativej1 4. 2 ...

  4. linux权限的深入讨论

    1.      怎样查看文件的权限 1)      掌握使用ls –l命令查看文件上所设定的权限. drwxr-xr-x. 2 root root 6 May 26 2017 binfmt.d 权限信 ...

  5. TransactionScope的用法

    using (TransactionScope ts = new TransactionScope()) { Model.user_login_log model = new Model.user_l ...

  6. oracle中提高order by的性能

    1.如果order by columnA,那么在where查询条件中添加条件columnA=value,则oracle内部会过滤order by排序,直接用索引(可以通过execution plan查 ...

  7. IOS设置图片背景

    在UIViewController里面这样设置: self.view.backgroundColor = [UIColor colorWithPatternImage: [UIImage imageN ...

  8. Markdown GUI编辑器推荐 windows mac

    windows 1. MarkdownPad 如果右边不能预览: LivePreview is not working - it displays an error message stating T ...

  9. ios -富文本和尺寸

    /** *  计算文本的宽高 方法 2 * *  @param str     需要计算的文本 *  @param font    文本显示的字体 *  @param maxSize 文本显示的范围 ...

  10. ios 获取手机设备信息

    [UIDevice currentDevice]:表示设备 NSString *devices=[[NSString alloc] initWithFormat: @"unique id: ...