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


C# JsonWriter.WriteArrayStart方法代码示例

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


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

示例1: WriteResponseForPostJson

    void WriteResponseForPostJson(HttpRequest request, HttpResponse response)
    {
        // read request JSON
        uint requestedCount = ReadCount(request.Body);

        // write response JSON
        var json = new JsonWriter<ResponseFormatter>(response.Body, prettyPrint: false);
        json.WriteObjectStart();
        json.WriteArrayStart();
        for (int i = 0; i < requestedCount; i++) {
            json.WriteString("hello!"); 
        }
        json.WriteArrayEnd();
        json.WriteObjectEnd();

        // write headers
        var headers = response.Headers;
        headers.AppendHttpStatusLine(HttpVersion.V1_1, 200, new Utf8String("OK"));
        headers.Append("Content-Length : ");
        headers.Append(response.Body.CommitedBytes);
        headers.AppendHttpNewLine();
        headers.Append("Content-Type : text/plain; charset=UTF-8");
        headers.AppendHttpNewLine();
        headers.Append("Server : .NET Core Sample Server");
        headers.AppendHttpNewLine();
        headers.Append("Date : ");
        headers.Append(DateTime.UtcNow, 'R');
        headers.AppendHttpNewLine();
        headers.AppendHttpNewLine();
    }
开发者ID:geoffkizer,项目名称:corefxlab,代码行数:30,代码来源:SampleServer.cs

示例2: WriteArray

		/// <summary>
		/// Write an array of target descriptors
		/// </summary>
		/// <param name="Writer">The Json writer to output to</param>
		/// <param name="Name">Name of the array</param>
		/// <param name="Targets">Array of targets</param>
		public static void WriteArray(JsonWriter Writer, string Name, LocalizationTargetDescriptor[] Targets)
		{
			if (Targets.Length > 0)
			{
				Writer.WriteArrayStart(Name);
				foreach (LocalizationTargetDescriptor Target in Targets)
				{
					Target.Write(Writer);
				}
				Writer.WriteArrayEnd();
			}
		}
开发者ID:zhaoyizheng0930,项目名称:UnrealEngine,代码行数:18,代码来源:LocalizationDescriptor.cs

示例3: JsonSerializer

    // Writer
    public static void JsonSerializer(JsonWriter writer, object instance)
    {
        var scoreEntry = (RankEntry)instance;

        writer.WriteArrayStart();
        writer.WriteNumber(scoreEntry.rankIndex);
        writer.WriteString(scoreEntry.accountId);
        writer.WriteString(scoreEntry.name);
        writer.WriteString(scoreEntry.country);
        writer.WriteNumber(scoreEntry.bestRanking);
        writer.WriteNumber(scoreEntry.totalDamage);
        writer.WriteArrayEnd();
    }
开发者ID:judah4,项目名称:battle-of-mages,代码行数:14,代码来源:RankEntry.cs

示例4: Write

		/// <summary>
		/// Reads a list of build steps from a Json project or plugin descriptor
		/// </summary>
		/// <param name="RawObject">The json descriptor object</param>
		/// <param name="FieldName">Name of the field to read</param>
		/// <param name="OutBuildSteps">Output variable to store the sorted dictionary that was read</param>
		/// <returns>True if the field was read (and OutBuildSteps is set), false otherwise.</returns>
		public void Write(JsonWriter Writer, string FieldName)
		{
			Writer.WriteObjectStart(FieldName);
			foreach(KeyValuePair<UnrealTargetPlatform, string[]> Pair in HostPlatformToCommands)
			{
				Writer.WriteArrayStart(Pair.Key.ToString());
				foreach(string Line in Pair.Value)
				{
					Writer.WriteValue(Line);
				}
				Writer.WriteArrayEnd();
			}
			Writer.WriteObjectEnd();
		}
开发者ID:zhaoyizheng0930,项目名称:UnrealEngine,代码行数:21,代码来源:CustomBuildSteps.cs

示例5: Write

 static void Write(JsonWriter json)
 {
     json.WriteObjectStart();
     json.WriteAttribute("age", 30);
     json.WriteAttribute("first", "John");
     json.WriteAttribute("last", "Smith");
     json.WriteMember("phoneNumbers");
     json.WriteArrayStart();
     json.WriteString("425-000-1212");
     json.WriteString("425-000-1213");
     json.WriteArrayEnd();
     json.WriteMember("address");
     json.WriteObjectStart();
     json.WriteAttribute("street", "1 Microsoft Way");
     json.WriteAttribute("city", "Redmond");
     json.WriteAttribute("zip", 98052);
     json.WriteObjectEnd();
     json.WriteObjectEnd();
 }
开发者ID:TerabyteX,项目名称:corefxlab,代码行数:19,代码来源:JsonWriterTests.cs

示例6: 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

示例7: WriteResponseForPostJson

    // This method is a bit of a mess. We need to fix many Http and Json APIs
    void WriteResponseForPostJson(BufferFormatter formatter, HttpRequestLine requestLine, ReadOnlySpan<byte> body)
    {
        Console.WriteLine(new Utf8String(body));

        uint requestedCount = ReadCountUsingReader(body).GetValueOrDefault(1);
        //uint requestedCount = ReadCountUsingNonAllocatingDom(body).GetValueOrDefault(1);

        // TODO: this needs to be written directly to the buffer after content length reservation is implemented.
        var buffer = ArrayPool<byte>.Shared.Rent(2048);
        var spanFormatter = new SpanFormatter(buffer.Slice(), FormattingData.InvariantUtf8);
        var json = new JsonWriter<SpanFormatter>(spanFormatter,  prettyPrint: true);
        json.WriteObjectStart();
        json.WriteArrayStart();
        for (int i = 0; i < requestedCount; i++) {
            json.WriteString(DateTime.UtcNow.ToString()); // TODO: this needs to not allocate.
        }
        json.WriteArrayEnd(); ;
        json.WriteObjectEnd();
        var responseBodyText = new Utf8String(buffer, 0, spanFormatter.CommitedByteCount);

        formatter.AppendHttpStatusLine(HttpVersion.V1_1, 200, new Utf8String("OK"));
        formatter.Append(new Utf8String("Content-Length : "));
        formatter.Append(responseBodyText.Length);
        formatter.AppendHttpNewLine();
        formatter.Append("Content-Type : text/plain; charset=UTF-8");
        formatter.AppendHttpNewLine();
        formatter.Append("Server : .NET Core Sample Serve");
        formatter.AppendHttpNewLine();
        formatter.Append(new Utf8String("Date : "));
        formatter.Append(DateTime.UtcNow.ToString("R"));
        formatter.AppendHttpNewLine();
        formatter.AppendHttpNewLine();
        formatter.Append(responseBodyText);

        ArrayPool<byte>.Shared.Return(buffer);
    }
开发者ID:tarekgh,项目名称:corefxlab,代码行数:37,代码来源:SampleServer.cs

示例8: SaveValueChange

    //保存所有修改后的值
    void SaveValueChange()
    {
        //文件输出流
        StreamWriter file = File.CreateText(s_FilePath);

        JsonWriter writer = new JsonWriter(file);

        writer.WriteArrayStart();
        for (int i = 0; i < SoundValue.Length; i++)
        {
            JsonMapper.ToJson(SoundValue[i], writer);
        }
        writer.WriteArrayEnd();

        file.Close();
    }
开发者ID:XvWenJun,项目名称:Retuer_6,代码行数:17,代码来源:SettingVolumeSave.cs

示例9: 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

示例10: WriteJsonToFile

 void WriteJsonToFile(string path,string fileName)
 {
     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);
     //创建文件目录
     DirectoryInfo dir = new DirectoryInfo(path);
     if (dir.Exists)
     {
         Debug.Log("This file is already exists");
     }
     else
     {
         Directory.CreateDirectory(path);
         Debug.Log("CreateFile");
     #if UNITY_EDITOR
         AssetDatabase.Refresh();
     #endif
     }
     //把json数据写到txt里
     StreamWriter sw;
     if (File.Exists(fileName))
     {
         //如果文件存在,那么就向文件继续附加(为了下次写内容不会覆盖上次的内容)
         sw = File.AppendText(fileName);
         Debug.Log("appendText");
     }
     else
     {
         //如果文件不存在则创建文件
         sw = File.CreateText(fileName);
         Debug.Log("createText");
     }
     sw.WriteLine(strB);
     sw.Close();
     #if UNITY_EDITOR
     AssetDatabase.Refresh();
     #endif
 }
开发者ID:wolf96,项目名称:Game-Pattern-Unity3d,代码行数:60,代码来源:JSON_TEST.cs

示例11: Write

		/// <summary>
		/// Write this module to a JsonWriter
		/// </summary>
		/// <param name="Writer">Writer to output to</param>
		void Write(JsonWriter Writer)
		{
			Writer.WriteObjectStart();
			Writer.WriteValue("Name", Name);
			Writer.WriteValue("Type", Type.ToString());
			Writer.WriteValue("LoadingPhase", LoadingPhase.ToString());
			if (WhitelistPlatforms != null && WhitelistPlatforms.Length > 0)
			{
				Writer.WriteArrayStart("WhitelistPlatforms");
				foreach (UnrealTargetPlatform WhitelistPlatform in WhitelistPlatforms)
				{
					Writer.WriteValue(WhitelistPlatform.ToString());
				}
				Writer.WriteArrayEnd();
			}
			if (BlacklistPlatforms != null && BlacklistPlatforms.Length > 0)
			{
				Writer.WriteArrayStart("BlacklistPlatforms");
				foreach (UnrealTargetPlatform BlacklistPlatform in BlacklistPlatforms)
				{
					Writer.WriteValue(BlacklistPlatform.ToString());
				}
				Writer.WriteArrayEnd();
			}
			if (AdditionalDependencies != null && AdditionalDependencies.Length > 0)
			{
				Writer.WriteArrayStart("AdditionalDependencies");
				foreach (string AdditionalDependency in AdditionalDependencies)
				{
					Writer.WriteValue(AdditionalDependency);
				}
				Writer.WriteArrayEnd();
			}
			Writer.WriteObjectEnd();
		}
开发者ID:zhaoyizheng0930,项目名称:UnrealEngine,代码行数:39,代码来源:ModuleDescriptor.cs

示例12: writeObject

	private static void writeObject(GameObject obj, ref JsonWriter cfg) {
		cfg.WriteObjectStart();
		cfg.WritePropertyName("name");
		cfg.Write(obj.name);
		cfg.WritePropertyName("Layer");
		cfg.Write(obj.layer);
		writeMatrix(ref cfg, obj.transform);

		if (obj.renderer) {
			Mesh mesh = obj.renderer.GetComponent<MeshFilter>().sharedMesh;
			if (obj.renderer.material.mainTexture != null) {
				cfg.WritePropertyName("MainTexture");
				cfg.Write(getFileName(AssetDatabase.GetAssetPath(obj.renderer.material.mainTexture.GetInstanceID())));
			}
			if (mesh) {
				cfg.WritePropertyName("Mesh");
				cfg.Write(mesh.name);
			}
			if (obj.renderer.lightmapIndex != -1) {
				cfg.WritePropertyName("lightmap");
				cfg.Write(LightmapSettings.lightmaps[obj.renderer.lightmapIndex].lightmapFar.name);
				cfg.WritePropertyName("tilingOffset");
				cfg.WriteArrayStart();
				cfg.Write(obj.renderer.lightmapTilingOffset.x);
				cfg.Write(obj.renderer.lightmapTilingOffset.y);
				cfg.Write(obj.renderer.lightmapTilingOffset.z);
				cfg.Write(obj.renderer.lightmapTilingOffset.w);
				cfg.WriteArrayEnd();
			}
		}

		cfg.WritePropertyName("children");
		cfg.WriteArrayStart();

		for (int i = 0; i < obj.transform.childCount; i++) {
			writeObject(obj.transform.GetChild(i).gameObject, ref cfg);
		}

		cfg.WriteArrayEnd();
		cfg.WriteObjectEnd();
	}
开发者ID:helojo,项目名称:Monkey,代码行数:41,代码来源:LightmapPlugin.cs

示例13: writeConfig

	private static void writeConfig() {
		JsonWriter cfg = new JsonWriter();
		cfg.WriteObjectStart();
		cfg.WritePropertyName("scene");
		cfg.WriteArrayStart();
		GameObject[] arr = Selection.gameObjects;
		foreach (GameObject obj in arr) {
			writeObject(obj, ref cfg);
		}
		cfg.WriteArrayEnd();
		cfg.WriteObjectEnd();

		string filepath = folderName + "/scene.lightmap";
		if (File.Exists(filepath)) {
			File.Delete(filepath);
		}
		FileStream fs = new FileStream(filepath, FileMode.Create);
		BinaryWriter bw = new BinaryWriter(fs);
		bw.Write(cfg.ToString().ToCharArray());
		bw.Close();
		fs.Close();
		Debug.Log("Write Config:" + filepath);
	}
开发者ID:helojo,项目名称:Monkey,代码行数:23,代码来源:LightmapPlugin.cs

示例14: CreateClothes

    public static void CreateClothes()
    {
        string rootName="DocTexts_ch";
        if(English_Caption){
            rootName="DocTexts_en";
        }
        TextAsset xmlAsset = Resources.Load<TextAsset>(rootName);
        string xmlContent = xmlAsset.text;

        StringBuilder sbuilders = new StringBuilder ();
        JsonWriter writer = new JsonWriter (sbuilders);
        writer.WriteObjectStart ();

        string[] captions = xmlContent.Split('?');
        foreach(string caption in captions)
        {
            writer.WritePropertyName ("captions");
            writer.WriteArrayStart();

            writer.WriteObjectStart ();
            string[] subtitles = caption.Split(';');

            writer.WritePropertyName ("subtitles");
            writer.WriteArrayStart();//[
            foreach (string subtitle in subtitles)
            {
                writer.WriteObjectStart();

                string[] parts=subtitle.Split('/');

                string time_from=parts[0];
                string time_to=parts[1];
                string article=parts[2];

                //1
                writer.WritePropertyName ("time_from");
                writer.Write (time_from);
                sbuilders.Append(System.Environment.NewLine);

                //2
                writer.WritePropertyName ("time_to");
                writer.Write (time_to);
                sbuilders.Append(System.Environment.NewLine);

                //3
                writer.WritePropertyName ("article");
                writer.Write (article);
                sbuilders.Append(System.Environment.NewLine);

                writer.WriteObjectEnd();
            }
            writer.WriteArrayEnd();
            writer.WriteObjectEnd();
            writer.WriteArrayEnd();
        }
        writer.WriteObjectEnd ();

        string clothFile=sbuilders.ToString();
        string desName="captions_ch.xml";
        if(English_Caption){
            desName="captions_en.xml";
        }

        System.IO.File.WriteAllText(Application.persistentDataPath+"/"+desName,clothFile);

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

示例15: 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


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