当前位置: 首页>>代码示例>>C#>>正文


C# JsonWriter.Write方法代码示例

本文整理汇总了C#中JsonWriter.Write方法的典型用法代码示例。如果您正苦于以下问题:C# JsonWriter.Write方法的具体用法?C# JsonWriter.Write怎么用?C# JsonWriter.Write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JsonWriter的用法示例。


在下文中一共展示了JsonWriter.Write方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ToString

 public override string ToString()
 {
     StringBuilder sb = new StringBuilder ();
     JsonWriter writer = new JsonWriter (sb);
     writer.WriteObjectStart ();
     writer.WritePropertyName ("option");
     writer.Write (option);
     writer.WritePropertyName ("subfield");
     writer.Write (subfield);
     writer.WritePropertyName ("tarId");
     writer.Write (tarId);
     writer.WriteObjectEnd ();
     return sb.ToString();
 }
开发者ID:fanqienano,项目名称:fanqietang,代码行数:14,代码来源:Option.cs

示例2: CreateClothes

    public static void CreateClothes()
    {
        string[] materials = Directory.GetFiles("Assets/characters_joysoft", "*.mat", SearchOption.AllDirectories);
        StringBuilder sbuilders = new StringBuilder ();
        JsonWriter writer = new JsonWriter (sbuilders);
        writer.WriteObjectStart ();
        foreach (string material in materials)
        {
            //Assets/characters_joysoft/Per Texture Materials/female_hair_01_01.mat
            string[] parts=material.Replace(".mat","").Split('/');
            string unit=parts[parts.Length-1];

            writer.WritePropertyName (unit);

            int hashkey=0;
            foreach(string key in defaultClothes){
                if(unit.Contains(key)){
                    hashkey=1;
                    break;
                }
            }
            writer.Write (""+hashkey);

            sbuilders.Append(System.Environment.NewLine);

        }
        writer.WriteObjectEnd ();

        UpdateClothesContent(sbuilders);

        Debug.Log("**********UpdateClothesContent Finish***********");
    }
开发者ID:yupassion,项目名称:Cinderella,代码行数:32,代码来源:CreateClothesData.cs

示例3: Deactivate

    void Deactivate()
    {
        state = 0;
        renderer.material.color = colours[0];

        StringBuilder sb = new StringBuilder();
        JsonWriter writer = new JsonWriter(sb);
        writer.WriteObjectStart();
        writer.WritePropertyName("id");
        writer.Write(id);
        writer.WritePropertyName("state");
        writer.Write(0);
        writer.WriteObjectEnd();

        monome.SendMessage("SendToSaul", sb.ToString());
    }
开发者ID:saulhardman,项目名称:monome,代码行数:16,代码来源:MonomeSquareBehaviour.cs

示例4: Main

        static void Main()
        {
            #if !DEBUG
            try {
            #endif
                // Load all configurations and if the config file does not exist, generate a new one.
            string settings_file = Path.Combine(Client.directory_app_data, "settings.dcf");

                Client.config = new Config(delegate(Config current_config) {
                    DC_Server[] server_list = new DC_Server[1];
                    server_list[0] = new DC_Server {
                        name = "NFGaming Upload Server",
                        url = "http://uploads.nfgaming.com",
                        times_connected = 0
                    };

                    current_config.set("frmlogin.servers_list", server_list);
                }, settings_file);

                // Set the max connections this program is allowed to have to a HTTP server.
                System.Net.ServicePointManager.DefaultConnectionLimit = Client.config.get<short>("net.default_connection_limit", 4);

                Client.config.save();

                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new frmLogin());

                // Run the cleanup script since the main form has been closed.
                cleanup();

            #if !DEBUG
            } catch(Exception e) {
                StringBuilder sb = new StringBuilder();
                JsonWriter jw = new JsonWriter(sb);
                DC_Exception exception = new DC_Exception() {
                    help_link = e.HelpLink,
                    inner_exception_message = (e.InnerException != null) ? e.InnerException.Message : null,
                    inner_exception_stack_trace = (e.InnerException != null)? e.InnerException.StackTrace : null,
                    source = e.Source,
                    stack_trace = e.StackTrace,
                    message = e.Message
                };

                jw.Write(exception);

                string args = Utilities.base64Encode(sb.ToString());
                args += " ";
                args += "http://dtronix.com/dtxCrashReporter/";

                System.Diagnostics.Process.Start("dtxCrashReporter.exe", args);
            }
            #endif
        }
开发者ID:DJGosnell,项目名称:dtronix-upload,代码行数:54,代码来源:Program.cs

示例5: OnGUI

    void OnGUI()
    {
        content = GUI.TextArea(new Rect(100, 100, 400, 100), content);

           /* if (GUI.Button(new Rect(330, 60, 60, 30), "Little jasson"))
        {
            Debug.Log("write jsson");

            TextWriter wr = new StreamWriter("students.txt");
            JsonWriter jsonwr = new JsonWriter(wr);
            jsonwr.IndentValue = 0;
            JsonMapper.ToJson(st1, jsonwr);
            jsonwr.WriteObjectStart();

            JsonMapper.ToJson(st2, jsonwr);
            wr.Close();

        }*/

        if (GUI.Button(new Rect(380, 60, 60, 30), "FX jasson"))
        {
            /*Классы короткая запись*/
            string json = JsonFx.Json.JsonWriter.Serialize(st1);
           // Debug.Log(json);
            Student st3 = JsonFx.Json.JsonReader.Deserialize<Student>(json);
            //Debug.Log("age " + st3.age + " count " + st3.count[5] + " name " + st3.name);

            /*массив*/

            JsonWriterSettings settw = new JsonWriterSettings();
            settw.TypeHintName = "__type";
            JsonReaderSettings settr = new JsonReaderSettings();
            settr.TypeHintName = "__type";

            /*пример чтоб разобраться, но либа работает только с классами нормально. */
            System.Text.StringBuilder builder=new System.Text.StringBuilder();
            JsonWriter wr = new JsonWriter(builder,settw);
                Student[] arr = new Student[3];
                arr[0] = st1;
                arr[1] = st2;
                arr[2] = st3;
                wr.Write(arr);
                System.IO.File.WriteAllText("testJSON.txt", builder.ToString());

            string jsonText = System.IO.File.ReadAllText("testJSON.txt");
            //Debug.Log(""+jsonText);
            Student[] tempSt = JsonReader.Deserialize<Student[]>(jsonText);
            content = "";
                foreach( var s in tempSt)
                    content +="" + s.name+System.Environment.NewLine;

        }
    }
开发者ID:justdude,项目名称:JSonFx-Unity3d,代码行数:53,代码来源:JSonHandler.cs

示例6: SaveData

	/// <summary>
	/// 数据存Json
	/// </summary>
	public void SaveData()
	{
		StringBuilder sb = new StringBuilder();
		JsonWriter jw = new JsonWriter(sb);
		jw.WriteObjectStart();
		//写入玩家名称
		jw.WritePropertyName("Name");
		jw.Write(GlobalManager.userName);
		//写入开始索引
		jw.WritePropertyName("StartIndex");
		jw.Write(GlobalManager.startIndex);
		//写入最高分
		jw.WritePropertyName("MaxScore");
		jw.Write(GlobalManager.maxScore);
		//写入已经完成的单词总数
		jw.WritePropertyName("WordAmount");
		jw.Write(GlobalManager.wordAmount);
		//...

		jw.WriteObjectEnd();
		SaveJsonString(sb.ToString());
	}
开发者ID:AhrenLi,项目名称:TypeWrite,代码行数:25,代码来源:DataManager.cs

示例7: SaveJson

    public static void SaveJson()
    {
        string filePath = Application.dataPath + @"/StringAssets/file/pos.txt";
        FileInfo fileInfo = new FileInfo(filePath);
        if (!File.Exists(filePath))
        {
            File.Delete(filePath);
        }

        StreamWriter sw = fileInfo.CreateText();
        StringBuilder sb = new StringBuilder();
        JsonWriter writer = new JsonWriter(sb);

        //从场景中开始一个个的遍历
        foreach (EditorBuildSettingsScene s in EditorBuildSettings.scenes)
        {
            if (s.enabled == true)
            {
                string name = s.path;
                EditorApplication.OpenScene(name);
                GameObject parent = GameObject.Find("PosObj");
                if (parent)
                {
                    writer.WriteArrayStart(); //开始写数据
                    for (int i = 0; i < parent.transform.childCount; i++)
                    {
                        Transform obj = parent.transform.GetChild(i);
                        writer.WriteObjectStart();
                        writer.WritePropertyName(obj.name);
                        writer.Write(obj.position.x.ToString() + "," + obj.position.y.ToString() + "," +
                                     obj.position.z.ToString());
                        writer.WriteObjectEnd();
                    }
                    writer.WriteArrayEnd();
                }
            }
        }

        sw.WriteLine(sb.ToString());
        sw.Close();
        sw.Dispose(); //关闭文件流
        AssetDatabase.Refresh();  //刷新
    }
开发者ID:dafei2015,项目名称:UIProject,代码行数:43,代码来源:EditorObjectPos.cs

示例8: PostTest1

    IEnumerator PostTest1()
    {
        string str = @"";
        // string like this
        // str = @"{""Id"":0,""IMEI"":""String"",""Phone"":""String"",""Name"":""String"",""Status"":0,""CreateTime"":""\/Date(-62135596800000+0800)\/"",""UpdateTime"":""\/Date(-62135596800000+0800)\/""}";
        // write Json
        JsonWriter writer = new JsonWriter();
        writer.WriteObjectStart();
        writer.WritePropertyName("Id");
        writer.Write(0);
        writer.WritePropertyName("IMEI");
        writer.Write("7654321");
        writer.WritePropertyName("Phone");
        writer.Write("13802817183");
        writer.WritePropertyName("Name");
        writer.Write("bbzm");
        writer.WritePropertyName("Status");
        writer.Write("1");
        writer.WritePropertyName("CreateTime");
        writer.Write("2013-01-01");
        writer.WritePropertyName("UpdateTime");
        writer.Write("2013-10-10");
        writer.WriteObjectEnd();
        str = writer.ToString();

        Debug.Log(str);
        WWWForm parameter = new WWWForm();
        parameter.AddField("Body", str);

        WWW postRequest = new WWW(@"http://192.168.133.225:82/Client/123456?format=json", parameter);
        yield return postRequest;

        JsonReader read = new JsonReader(postRequest.text);
        Debug.Log(postRequest.text);
        Debug.Log(" ----------------- ");
        while (read.Read())
        {
            Debug.Log(read.Token + " : " + read.Value + " : " + read.GetType().ToString());
        }
        Debug.Log(" ----------------- ");
    }
开发者ID:bbknightzm,项目名称:unitySample,代码行数:41,代码来源:HttpPostTest.cs

示例9: Export

        public void Export(bool run)
        {
            try
            {
                string sceneName = EditorSceneManager.GetActiveScene().name;

                exportationOptions.DefaultFolder = EditorUtility.SaveFolderPanel("Please select a folder", exportationOptions.DefaultFolder, "");

                if (string.IsNullOrEmpty(exportationOptions.DefaultFolder))
                {
                    return;
                }

                Stopwatch watch = new Stopwatch();

                watch.Start();

                var jsWriter = new JsonWriter();
                File.WriteAllText("Unity3D2Babylon.ini", jsWriter.Write(exportationOptions));
                logs.Clear();

                ReportProgress(0);

                var sceneBuilder = new SceneBuilder(exportationOptions.DefaultFolder, sceneName, exportationOptions);

                sceneBuilder.ConvertFromUnity();

                ReportProgress(1, "Generating output file");
                var outputFile = sceneBuilder.WriteToBabylonFile();

                watch.Stop();
                ReportProgress(1, string.Format("Exportation done in {0:0.00}s", watch.Elapsed.TotalSeconds));
                EditorUtility.ClearProgressBar();

                sceneBuilder.GenerateStatus(logs);

                ShowMessage("Exportation done");

                if (run)
                {
                    WebServer.SceneFolder = Path.GetDirectoryName(outputFile);
                    WebServer.SceneFilename = Path.GetFileName(outputFile);

                    Process.Start("http://localhost:" + WebServer.Port);
                }
            }
            catch (Exception ex)
            {
                EditorUtility.ClearProgressBar();
                ShowMessage("A problem occurred: " + ex.Message + ex.StackTrace, "Error");
            }
        }
开发者ID:CreateAppAdmin,项目名称:Babylon.js,代码行数:52,代码来源:ExporterWindow.cs

示例10: WriteJsonAndPrint

 void WriteJsonAndPrint()
 {
     System.Text.StringBuilder strB = new System.Text.StringBuilder();
     JsonWriter jsWrite = new JsonWriter(strB);
     jsWrite.WriteObjectStart();
     jsWrite.WritePropertyName("Name");
     jsWrite.Write("taotao");
     jsWrite.WritePropertyName("Age");
     jsWrite.Write(25);
     jsWrite.WritePropertyName("MM");
     jsWrite.WriteArrayStart();
     jsWrite.WriteObjectStart();
     jsWrite.WritePropertyName("name");
     jsWrite.Write("xiaomei");
     jsWrite.WritePropertyName("age");
     jsWrite.Write("17");
     jsWrite.WriteObjectEnd();
     jsWrite.WriteObjectStart();
     jsWrite.WritePropertyName("name");
     jsWrite.Write("xiaoli");
     jsWrite.WritePropertyName("age");
     jsWrite.Write("18");
     jsWrite.WriteObjectEnd();
     jsWrite.WriteArrayEnd();
     jsWrite.WriteObjectEnd();
     Debug.Log(strB);
     JsonData jd = JsonMapper.ToObject(strB.ToString());
     Debug.Log("name=" + jd["Name"]);
     Debug.Log("age=" + jd["Age"]);
     JsonData jdItems = jd["MM"];
     for (int i = 0; i < jdItems.Count; i++)
     {
         Debug.Log("MM name=" + jdItems["name"]);
         Debug.Log("MM age=" + jdItems["age"]);
     }
 }
开发者ID:wolf96,项目名称:Game-Pattern-Unity3d,代码行数:36,代码来源:JSON_TEST.cs

示例11: ExportParameterFile

        private void ExportParameterFile()
        {
            // Output the settings to INI for viewing.
            var outParamName = Path.GetFileNameWithoutExtension(m_config.ParameterFile);
            if (outParamName == null)
                return;

            var outParamPath = Path.Combine(m_config.AnalysisPath, outParamName);
            var writer = new JsonWriter<MultiAlignAnalysisOptions>();
            writer.Write(outParamPath + ".json", m_config.Analysis.Options);
        }
开发者ID:msdna,项目名称:MultiAlign,代码行数:11,代码来源:AnalysisController.cs

示例12: SaveLocal

    public void SaveLocal()
    {
        var charWriter = new JsonWriter(new JsonFx.Serialization.DataWriterSettings(new JsonFx.Json.Resolvers.JsonResolverStrategy()));
        var charData = charWriter.Write(Characters);

        var filePath = Application.dataPath + @"/Data/save.json";

        using (var saveFile = new StreamWriter(filePath))
        {
            saveFile.Write(charData);
        }
    }
开发者ID:wskidmore,项目名称:mdc,代码行数:12,代码来源:CharacterManager.cs

示例13: ExportScenesToJSON

    public static void ExportScenesToJSON()
    {
        string path = EditorUtility.SaveFilePanel("SaveJason", Application.dataPath, "Scenes_Config_JSON", "txt");
        FileInfo fileInfo = new FileInfo(path);
        StreamWriter sw = fileInfo.CreateText();

        StringBuilder sb = new StringBuilder();
        JsonWriter writer = new JsonWriter(sb);
        writer.WriteObjectStart();
        writer.WritePropertyName("root");
        writer.WriteArrayStart();

        foreach (EditorBuildSettingsScene S in EditorBuildSettings.scenes)
        {
            if (S.enabled)
            {
                EditorApplication.OpenScene(S.path);
                writer.WriteObjectStart();
                writer.WritePropertyName("Scene");
                writer.WriteArrayStart();
                writer.WriteObjectStart();
                writer.WritePropertyName("SceneName");
                writer.Write(S.path);
                writer.WritePropertyName("GameObjects");
                writer.WriteArrayStart();

                foreach (GameObject obj in Object.FindObjectsOfType(typeof(GameObject)))
                {
                    if (obj.transform.parent == null)
                    {
                        writer.WriteObjectStart();
                        writer.WritePropertyName("GameObjectName");
                        writer.Write(obj.name);

                        writer.WritePropertyName("Position");
                        writer.WriteArrayStart();
                        writer.WriteObjectStart();
                        writer.WritePropertyName("X");
                        writer.Write(obj.transform.position.x.ToString("F5"));
                        writer.WritePropertyName("Y");
                        writer.Write(obj.transform.position.y.ToString("F5"));
                        writer.WritePropertyName("Z");
                        writer.Write(obj.transform.position.z.ToString("F5"));
                        writer.WriteObjectEnd();
                        writer.WriteArrayEnd();

                        writer.WritePropertyName("Rotation");
                        writer.WriteArrayStart();
                        writer.WriteObjectStart();
                        writer.WritePropertyName("X");
                        writer.Write(obj.transform.rotation.eulerAngles.x.ToString("F5"));
                        writer.WritePropertyName("Y");
                        writer.Write(obj.transform.rotation.eulerAngles.y.ToString("F5"));
                        writer.WritePropertyName("Z");
                        writer.Write(obj.transform.rotation.eulerAngles.z.ToString("F5"));
                        writer.WriteObjectEnd();
                        writer.WriteArrayEnd();

                        writer.WritePropertyName("Scale");
                        writer.WriteArrayStart();
                        writer.WriteObjectStart();
                        writer.WritePropertyName("X");
                        writer.Write(obj.transform.localScale.x.ToString("F5"));
                        writer.WritePropertyName("Y");
                        writer.Write(obj.transform.localScale.y.ToString("F5"));
                        writer.WritePropertyName("Z");
                        writer.Write(obj.transform.localScale.z.ToString("F5"));
                        writer.WriteObjectEnd();
                        writer.WriteArrayEnd();

                        writer.WriteObjectEnd();
                    }
                }

                writer.WriteArrayEnd();
                writer.WriteObjectEnd();
                writer.WriteArrayEnd();
                writer.WriteObjectEnd();
            }
        }
        writer.WriteArrayEnd();
        writer.WriteObjectEnd();
        sw.WriteLine(sb.ToString());
        sw.Close();
        sw.Dispose();
        AssetDatabase.Refresh();
    }
开发者ID:gggg826,项目名称:LETools,代码行数:87,代码来源:LETools.cs

示例14: toJson

 public virtual String toJson()
 {
     var writer = new JsonWriter();
     return writer.Write(this);
 }
开发者ID:TomCaserta,项目名称:AlternateController,代码行数:5,代码来源:ClientToServerPackets.cs

示例15: PostURL

    /// <summary>
    /// Post to a a URL endpoint with required field(s) and gives an optional response handler.
    /// </summary>
    /// <param name="url">The URL to post to.</param>
    /// <param name="responseHandler">An Action that handles the response (optional).</param>
    public void PostURL(string url, Dictionary<string, object> fields, Action<Dictionary<string, object>> responseHandler=null) {

        // Kill networking immediately if no connection
        // if(Application.internetReachability == NetworkReachability.NotReachable)
        //     KillNetwork(true);

        if(_ignoreNetwork) {
            fields.Add("local", true);
            responseHandler(fields);
            return;
        }

        string absoluteURL = DataManager.RemoteURL + url;

        // Send form as raw byte array
        System.Text.StringBuilder output = new System.Text.StringBuilder();
        
        JsonWriter writer = new JsonWriter (output);
        
        if(_sessionCookie != null)
            fields.Add("sessionID", System.Convert.ChangeType(_sessionCookie, typeof(object)));
        
        // If no session cookie, client has no auth, so cache this request to do later
        else if(url != "/auth/") {
            PostCache cacheObj = new PostCache();
            cacheObj.url = url;
            cacheObj.fields = fields;
            cacheObj.responseHandler = responseHandler;
            _cachedRequests.Add(cacheObj);

            return;
        }

        writer.Write(fields);
     
        // Encode output as UTF8 bytes
        _currentRoutine = WaitForForm(absoluteURL, Encoding.UTF8.GetBytes(output.ToString()), responseHandler);
        StartCoroutine(_currentRoutine);
    
    }
开发者ID:engagementgamelab,项目名称:AtStake_v2,代码行数:45,代码来源:ApiManager.cs


注:本文中的JsonWriter.Write方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。