コード例 #1
0
    public List <List <string> > ticketsList; //股票列表
    // Use this for initialization
    void Start()
    {
        //初始化,游戏开始读取文件
        //
        TicketDataList datalist = LoadFromJson("/GameTicketData.json");

        data = datalist.list;
        //query ();

        /*List<ArrayList> temp = GetTickets ();
         * for (int j = 0 ;j < temp.Count; j++) {
         *
         *      for (int i = 0; i < temp[j].Count; i++)
         *              Debug.Log (temp[j][i]);
         * }*/
    }
コード例 #2
0
    //将股市中的股票数量写入json进行保存
    public bool WriteToJson(string path)
    {
        StreamWriter sw;
        FileInfo     f = new FileInfo(Application.dataPath + path);

        if (f.Exists)
        {
            f.Delete();
        }
        sw = f.CreateText();

        TicketDataList datalist = new TicketDataList();

        datalist.list = data;
        string json = JsonUtility.ToJson(datalist);

        sw.WriteLine(json);
        sw.Close();
        sw.Dispose();
        return(true);
    }