资源简介
unity2018的 Json 文件的序列化反序列化读写工程,主要是支持反序列化读取Json文件,序列化写入Json文件的unity2018的Demo。里面自带了Newtonsoft.Json的Newtonsoft.Json.dll。
代码片段和文件信息
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Newtonsoft.Json;
using System;
using System.Text;
using System.IO;
public class CSerializer : MonoBehaviour
{
private void Start()
{
string path = Application.dataPath + “/test.json“;
Product products = new Product();
products.dic[“字典key“] = “字典Value“;
products.name = “字符test“;
string sjson = JsonConvert.Serializeobject(products);
File.WriteAllText(path sjson Encoding.UTF8);
Product mProduct = JsonConvert.Deserializeobject(sjson);
Debug.Log(sjson);
Debug.Log(mProduct.name);
path = Application.dataPath + “/inputdate.json“;
//序列换格式1
JsonData jsonData = new JsonData();
jsonData.Int = 1;
jsonData.String = “123“;
jsonData.Float = 1.33f;
jsonData.Double = 3.2;
//转Json
string jsons = JsonConvert.Serializeobject(jsonData);
//File.WriteAllText(path jsons Encoding.UTF8);
Debug.Log(“序列换格式1“+jsons);
//序列换格式2
Product product = new Product();
product.dic[“键“] = “值“;
product.name = “字符“;
string json = JsonConvert.Serializeobject(product);
File.WriteAllText(path json Encoding.UTF8);
Debug.Log(“序列换格式2“ + json);
//获取文件路径。
if (File.Exists(path)) //如果该文件存在。
{
string dataAsJson = File.ReadAllText(path); //读取所有数据送到json格式的字符串里面。
//直接赋值。FromJson
Product m = JsonConvert.Deserializeobject(dataAsJson);
//使用已有对象,添加值。FromJsonOverwrite
//loadedData = new MyData();
//JsonUtility.FromJsonOverwrite(dataAsJson loadedData);
Debug.Log(“---“+m.name);
}
}
}
[Serializable]
public class CharacterListItem
{
public int Id { get; set; }
public string Name { get; set; }
public int Level { get; set; }
public string Class { get; set; }
public string Sex { get; set; }
}
public class JsonData
{
public int Int;
public float Float;
public string String;
public double Double;
}
public class Product
{
public string name;
public Dictionary dic = new Dictionary();
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2019-07-23 02:37 Json_Serializer_ReadAndWrite\
目录 0 2019-07-23 01:43 Json_Serializer_ReadAndWrite\.vs\
目录 0 2019-07-23 01:43 Json_Serializer_ReadAndWrite\.vs\config\
文件 82755 2018-06-26 21:12 Json_Serializer_ReadAndWrite\.vs\config\applicationhost.config
目录 0 2019-07-23 01:16 Json_Serializer_ReadAndWrite\.vs\Json_Serializer_ReadAndWrite\
目录 0 2019-07-23 01:16 Json_Serializer_ReadAndWrite\.vs\Json_Serializer_ReadAndWrite\DesignTimeBuild\
文件 168 2019-07-23 02:37 Json_Serializer_ReadAndWrite\.vs\Json_Serializer_ReadAndWrite\DesignTimeBuild\.dtbcache
目录 0 2019-07-23 01:02 Json_Serializer_ReadAndWrite\.vs\Json_Serializer_ReadAndWrite\v15\
文件 242176 2019-07-23 02:37 Json_Serializer_ReadAndWrite\.vs\Json_Serializer_ReadAndWrite\v15\.suo
目录 0 2019-07-23 01:00 Json_Serializer_ReadAndWrite\.vs\Json_Serializer_ReadAndWrite\v15\Server\
目录 0 2019-07-23 01:00 Json_Serializer_ReadAndWrite\.vs\Json_Serializer_ReadAndWrite\v15\Server\sqlite3\
文件 0 2019-07-23 01:00 Json_Serializer_ReadAndWrite\.vs\Json_Serializer_ReadAndWrite\v15\Server\sqlite3\db.lock
文件 958464 2019-07-23 01:51 Json_Serializer_ReadAndWrite\.vs\Json_Serializer_ReadAndWrite\v15\Server\sqlite3\storage.ide
文件 32768 2019-07-23 02:36 Json_Serializer_ReadAndWrite\.vs\Json_Serializer_ReadAndWrite\v15\Server\sqlite3\storage.ide-shm
文件 4136512 2019-07-23 02:37 Json_Serializer_ReadAndWrite\.vs\Json_Serializer_ReadAndWrite\v15\Server\sqlite3\storage.ide-wal
文件 41959 2019-07-23 02:37 Json_Serializer_ReadAndWrite\Assembly-CSharp.csproj
目录 0 2019-07-23 02:36 Json_Serializer_ReadAndWrite\Assets\
文件 40 2019-07-23 02:37 Json_Serializer_ReadAndWrite\Assets\inputdate.json
文件 158 2019-07-23 01:38 Json_Serializer_ReadAndWrite\Assets\inputdate.json.me
文件 552872 2018-11-27 18:07 Json_Serializer_ReadAndWrite\Assets\Newtonsoft.Json.dll
文件 569 2019-07-23 01:02 Json_Serializer_ReadAndWrite\Assets\Newtonsoft.Json.dll.me
目录 0 2019-07-23 02:33 Json_Serializer_ReadAndWrite\Assets\Scenes\
文件 180 2018-05-09 22:30 Json_Serializer_ReadAndWrite\Assets\Scenes.me
文件 7649 2019-07-23 02:33 Json_Serializer_ReadAndWrite\Assets\Scenes\SampleScene.unity
文件 162 2018-05-09 22:30 Json_Serializer_ReadAndWrite\Assets\Scenes\SampleScene.unity.me
目录 0 2019-07-23 02:37 Json_Serializer_ReadAndWrite\Assets\sc
文件 172 2019-07-23 00:59 Json_Serializer_ReadAndWrite\Assets\sc
文件 2598 2019-07-23 02:37 Json_Serializer_ReadAndWrite\Assets\sc
文件 243 2019-07-23 00:59 Json_Serializer_ReadAndWrite\Assets\sc
文件 58 2019-07-23 02:37 Json_Serializer_ReadAndWrite\Assets\test.json
文件 158 2019-07-23 01:44 Json_Serializer_ReadAndWrite\Assets\test.json.me
............此处省略1154个文件信息
相关资源
- unity2018中的spine骨骼动画运行库
- unity2018 package manager引入本地包Demo
- shaderforge支持unity2018的源代码和插件
- Newtonsoft.Json各个平台版本.NET20/30/40/
- Shader Forge 1.3.8.0_unity2018.unitypackage
- ShaderForge兼容Unity2018版本
- Newtonsoft.Json
- PostProcessing unity2018
- playmaker 1.9.0p2 unity2018可用
- Unity 2018 Shaders and Effects Cookbook 3rd
- AnyPortrait 1.1.5-unity2018.3.2验证通过
- Newtonsoft.Json.dll组件
- unity2018版汉化包
- Newtonsoft.Json.Compact .dll v3.5.0.8
- newtonsoft.json源码
- Unity2018 Behavior Designer
- 嵌入式 WinCE 专用 Newtonsoft.Json.dll 亲测
- 使用Unity物理实现规定抛物线击中目标
- Newtonsoft.Json.dll For .Net 4.5
- Unity2018官方汉化包
- Newtonsoft.Json6.0.0.0
- Json.NET中文文档
- unity2018破解,unipatcher2018.7z
- Newtonsoft.Json.Net_2.0 _3.5_4.0 _4.5
- Unity2018.3.0 版本以上使用的TextMeshPro
- Newtonsoft.Json.dll(版本:3.5.0.0)
- Newtonsoft.Json.dll .NET 2.0版本
- Newtonsoft.Json2.0
- Newtonsoft.Json.Net 包括: .NET 2 .NET 3.5 .N
- Newtonsoft.Json.dll(.NET2.0_3.5_4.0_4.5)
评论
共有 条评论