Creating A Nested JSON Object In C#

Hi All
I search hole internet and i can’t find solution for question title!
also i’m new in Json c#!
I want to create Json like this:

	"unique_device_id": "1234569877227",
	"device_model": "x3",
	"os": "android",
	"os_version": "1.2",
	"user_id": "",
		"deviceModel": "Aspire",
		"deviceName": "Dell",
		"deviceType": "laptop",
		"deviceUniqueIdentifier": "12654311",

also meta key, can be an array.
how can i do this with JsonUtility ?

Best Regards

OK, I try this and it work perfectly

i serialize my class:

    public class DeviceInfoSerialzeClass
        public string unique_device_id;
        public string device_model;
        public string os;
        public string os_version;
        public string user_id;
        public List<Meta> meta;

and Meta Class:

public class Meta

    public string deviceModel;
    public string devicename;
    public string deviceType;
    public string deviceUniqueIdentifier;



create method like this:

 public void WritePlayer()
        DeviceInfoSerialzeClass writePlayer = new DeviceInfoSerialzeClass()
            unique_device_id = "Unique 321465461",
            device_model = SystemInfo.deviceModel.ToString(),
            os = SystemInfo.deviceName.ToString(),
            os_version = SystemInfo.deviceType.ToString(),
            user_id = SystemInfo.deviceUniqueIdentifier.ToString(),
            meta = new List<Meta>
                new Meta()
                    deviceName = SystemInfo.graphicsDeviceName.ToString(),
                    graphicDeviceType = SystemInfo.graphicsDeviceType.ToString(),
                    graphicDeviceVendor = SystemInfo.graphicsDeviceVendor.ToString(),
                    graphicDeviceVendorID = SystemInfo.graphicsDeviceVendorID.ToString(),
                    graphicDeviceVersion = SystemInfo.graphicsDeviceVersion.ToString(),


        if (deviceModel == "")


and :

public static void WritePlayerJSON(DeviceInfoSerialzeClass player)
    string jsonString = JsonUtility.ToJson(player);
    string filePath = Path.Combine(Application.dataPath, "saveData.json");
    File.WriteAllText(filePath, jsonString);

So i just call the method and my saveData.json file created this:

	"unique_device_id": "Unique 321465461",
	"device_model": "Aspire 5750G (Acer)",
	"os": "NOVIN_PENDAR",
	"os_version": "Desktop",
	"user_id": "2f67c674f387669ce22246c5f2fab212da06220c",
			"deviceModel": "",
			"deviceName": "Emulated GPU running OpenGL ES 3.0",
			"deviceType": "",
			"deviceUniqueIdentifier": "",
			"graphicDeviceId": "",
			"graphicDeviceName": "",
			"graphicDeviceType": "Direct3D11",
			"graphicDeviceVendor": "Emulated",
			"graphicDeviceVendorID": "32902",
			"graphicDeviceVersion": "OpenGL ES 3.0 [emulated]"

it seems ok! please tell me if i’m wrong! (sorry for my bad english)