facebook twitter hatena line email

「Unity/Csharp/Json/NewtonJson」の版間の差分

提供: 初心者エンジニアの簡易メモ
移動: 案内検索
(NewtonJsonのdllをDL)
(NewtonJsonのdllをDL)
行1: 行1:
 
==NewtonJsonのdllをDL==
 
==NewtonJsonのdllをDL==
#https://www.nuget.org/packages/Newtonsoft.Json
+
#https://www.nuget.org/packages/Newtonsoft.Json をDLし、.nupkgを.zipに変更し、解凍。
をDLし、.nupkgを.zipに変更し、解凍。
+
 
#lib\netstandard2.0の下のNewtonsoft.Json.dllをPluginsの下に設置
 
#lib\netstandard2.0の下のNewtonsoft.Json.dllをPluginsの下に設置
  

2021年7月5日 (月) 16:08時点における版

NewtonJsonのdllをDL

  1. https://www.nuget.org/packages/Newtonsoft.Json をDLし、.nupkgを.zipに変更し、解凍。
  2. lib\netstandard2.0の下のNewtonsoft.Json.dllをPluginsの下に設置

サンプル

using UnityEngine;
using Newtonsoft.Json;
using System;
public class SampleScene : MonoBehaviour
{
    [Serializable]
    public class Item
    {
        public string Name;
        public int Value;
    }
    void Start()
    {
        Item itemSource = new Item();
        itemSource.Name = "aaa";
        itemSource.Value = 111;
        string json = JsonConvert.SerializeObject(itemSource);
        Item item = JsonConvert.DeserializeObject<Item>(json);
        Debug.Log("name=" + item.Name + " value=" + item.Value);
    }
}

ログ:name=aaa value=111

参考

https://qiita.com/safu9/items/b9f654a5083d794442a2

https://spi8823.hatenablog.com/entry/2016/04/16/001641