リポジトリ
使用例
using System.Text.Encodings.Web;
using System.Text.Json;
using UnityEngine;
public sealed class Character
{
public int Id { get; set; }
public string Name { get; set; }
}
public class Example : MonoBehaviour
{
private void Start()
{
var characters = new Character[]
{
new() { Id = 1, Name = "フシギダネ" },
new() { Id = 2, Name = "フシギソウ" },
new() { Id = 3, Name = "フシギバナ" },
};
var options = new JsonSerializerOptions
{
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping,
WriteIndented = true,
};
var json = JsonSerializer.Serialize( characters, options );
Debug.Log( json );
}
}