페이지

2016년 7월 31일 일요일

Json array to Object array


JSON Array

string returnString;

returnString=
{
    "object": 
    {
        "name": "nm",
        "place": "plc",
        "description": "dscrptn",
    },
    {
        "name": "nm",
        "place": "plc",
        "description": "dscrptn",
    },
    {
        "name": "nm",
        "place": "plc",
        "description": "dscrptn",
    },
}



  1. [System.Serializable]
  2. public struct MyObject
  3. {
  4.    [System.Serializable]
  5.    public struct ArrayEntry
  6.    {
  7.       public string name;
  8.       public string place;
  9.       public string description;
  10.    }
  11.  
  12.    public ArrayEntry[] object;
  13. }


MyObject obj = JsonUtility.FromJson<MyObject>(returnString);
string strJson = JsonUtility.ToJson(obj);