【Unity&JSON】LitJson的多对象读写(3)

本文介绍了如何使用Unity结合LitJson库,将包含多个内嵌对象的数据序列化为JSON格式并保存到文件。通过创建InnerObjectData_LitJson类表示玩家数据,然后将其存储到List中,转换为主对象MainObjectData_LitJson的数组,最后将整个对象序列化为JSON字符串并写入到Resources目录下的Json_ObjectArray.json文件。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

原文内容来自:Read from and write to external .json files using JsonUtilities or LitJson

文件Unity 版本号5.3,使用时候Unity 版本号5.6

文件分流unity-json-master

本文仅作分析,学习用途。


_3WriteJson_ObjectArray_LitJson

----------------------------------------------------------------------------------------------原代码+注释

// Transform objects to a JSON-formatted string and save it into a file.
// using LitJson
// storing nested objects in array
// creating {"highscore":[{"name":"MagicMike","scores":8828},{"name":"MadMax","scores":4711}]}

using UnityEngine;
using LitJson;
using System.IO;
using System.Collections.Generic;


public class _3WriteJson_ObjectArray_LitJson : MonoBehaviour

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值