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


C# JsonWriter.Write方法代码示例

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


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

示例1: LitJsonWriterObjects

        public static void LitJsonWriterObjects ()
        {
            for (int j = 0; j < Common.Iterations; j++) {
                StringBuilder output = new StringBuilder ();
                JsonWriter writer = new JsonWriter (new StringWriter (output));

                int n = Common.SampleObject.Length;
                for (int i = 0; i < n; i += 2) {
                    switch ((char) Common.SampleObject[i]) {
                    case '{':
                        writer.WriteObjectStart ();
                        break;

                    case '}':
                        writer.WriteObjectEnd ();
                        break;

                    case '[':
                        writer.WriteArrayStart ();
                        break;

                    case ']':
                        writer.WriteArrayEnd ();
                        break;

                    case 'P':
                        writer.WritePropertyName (
                            (string) Common.SampleObject[i + 1]);
                        break;

                    case 'I':
                        writer.Write (
                            (int) Common.SampleObject[i + 1]);
                        break;

                    case 'D':
                        writer.Write (
                            (double) Common.SampleObject[i + 1]);
                        break;

                    case 'S':
                        writer.Write (
                            (string) Common.SampleObject[i + 1]);
                        break;

                    case 'B':
                        writer.Write (
                            (bool) Common.SampleObject[i + 1]);
                        break;

                    case 'N':
                        writer.Write (null);
                        break;
                    }
                }

            }
        }
开发者ID:chenchen2015,项目名称:litjson,代码行数:58,代码来源:BmLitJsonWriter.cs

示例2: ErrorExcessDataTest

        public void ErrorExcessDataTest()
        {
            JsonWriter writer = new JsonWriter ();

            writer.WriteArrayStart ();
            writer.Write (true);
            writer.WriteArrayEnd ();
            writer.Write (false);
        }
开发者ID:kvantetore,项目名称:litjson,代码行数:9,代码来源:JsonWriterTest.cs

示例3: ToNetMsg

        public static void ToNetMsg(Dictionary<long, F3_NetServerInfo> servers, ref NetOutgoingMessage netMsg)
        {
            netMsg.Write((byte)NetDataType.eDATA_REQUEST_SERVER_LIST);

            StringBuilder sb = new StringBuilder();
            JsonWriter writer = new JsonWriter(sb);

            writer.WriteObjectStart();
            writer.WritePropertyName("servers");
            writer.WriteArrayStart();

            for (int i = 0; i < servers.Count; i++)
            {
                F3_NetServerInfo info = servers.ElementAt(i).Value;
                writer.WriteObjectStart();

                writer.WritePropertyName("UUID");
                writer.Write(servers.ElementAt(i).Key);

                writer.WritePropertyName("serverName");
                writer.Write(info.m_serverName);

                writer.WritePropertyName("type");
                writer.Write((int)info.m_serverType);

                writer.WritePropertyName("internal_ip");
                writer.Write(info.m_serverInternalAdress.Address.ToString());

                writer.WritePropertyName("internal_port");
                writer.Write(info.m_serverInternalAdress.Port);

                writer.WritePropertyName("external_ip");
                writer.Write(info.m_serverExternalAdress.Address.ToString());

                writer.WritePropertyName("external_port");
                writer.Write(info.m_serverExternalAdress.Port);

                writer.WritePropertyName("maxPlayers");
                writer.Write(info.m_maxPlayers);

                writer.WritePropertyName("currentPlayers");
                writer.Write(info.m_currentNbPlayers);

                writer.WritePropertyName("token");
                writer.Write(info.m_NATtoken);

                writer.WriteObjectEnd();
            }

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

            netMsg.Write(sb.ToString());
        }
开发者ID:SharpEdgeEntertainment,项目名称:FrozenFlameFramework,代码行数:54,代码来源:F3.+NetMessageRequestServerList.cs

示例4: BooleansTest

        public void BooleansTest()
        {
            JsonWriter writer = new JsonWriter ();

            writer.WriteArrayStart ();
            writer.Write (true);
            writer.Write (false);
            writer.Write (false);
            writer.Write (true);
            writer.WriteArrayEnd ();
        }
开发者ID:kvantetore,项目名称:litjson,代码行数:11,代码来源:JsonWriterTest.cs

示例5: generateReadParamJson

 public static string generateReadParamJson()
 {
     System.Text.StringBuilder sb = new System.Text.StringBuilder();
     JsonWriter writer = new JsonWriter(sb);
     writer.WriteObjectStart();
     writer.WritePropertyName("action");
     writer.Write("get");
     writer.WritePropertyName("id");
     writer.Write("SC9008637");
     writer.WritePropertyName("page");
     writer.Write("channel_param");
     writer.WriteObjectEnd();
     return sb.ToString();
 }
开发者ID:BUPTSSECommunity,项目名称:Nuclide-PC,代码行数:14,代码来源:DetectorParam.cs

示例6: ListStepDefinitionsAsJson

 public string ListStepDefinitionsAsJson()
 {
     StringBuilder sb = new StringBuilder();
     JsonWriter writer = new JsonWriter(sb);
     writer.WriteArrayStart();
     foreach (StepDefinition sd in _stepDefinitions)
     {
         writer.WriteObjectStart();
         writer.WritePropertyName("id");
         writer.Write(sd.Id);
         writer.WritePropertyName("regexp");
         writer.Write(sd.Pattern);
         writer.WriteObjectEnd();
     }
     writer.WriteArrayEnd();
     return sb.ToString();
 }
开发者ID:mscottford,项目名称:Cuke4Nuke,代码行数:17,代码来源:StepDefinitionRepository.cs

示例7: LitJsonWriterNumbers

        public static void LitJsonWriterNumbers ()
        {
            for (int i = 0; i < Common.Iterations; i++) {
                StringBuilder output = new StringBuilder ();
                JsonWriter writer = new JsonWriter (new StringWriter (output));

                writer.WriteArrayStart ();

                foreach (int n in Common.SampleInts)
                    writer.Write (n);

                foreach (double n in Common.SampleDoubles)
                    writer.Write (n);

                writer.WriteArrayEnd ();
            }
        }
开发者ID:chenchen2015,项目名称:litjson,代码行数:17,代码来源:BmLitJsonWriter.cs

示例8: ErrorArrayClosingTest

        public void ErrorArrayClosingTest()
        {
            JsonWriter writer = new JsonWriter ();

            writer.WriteArrayStart ();
            writer.Write (true);
            writer.WriteObjectEnd ();
        }
开发者ID:kvantetore,项目名称:litjson,代码行数:8,代码来源:JsonWriterTest.cs

示例9: ErrorObjectClosingTest

        public void ErrorObjectClosingTest()
        {
            JsonWriter writer = new JsonWriter ();

            writer.WriteObjectStart ();
            writer.WritePropertyName ("foo");
            writer.Write ("bar");
            writer.WriteArrayEnd ();
        }
开发者ID:kvantetore,项目名称:litjson,代码行数:9,代码来源:JsonWriterTest.cs

示例10: StringBuilderTest

        public void StringBuilderTest()
        {
            StringBuilder sb = new StringBuilder ();
            JsonWriter writer = new JsonWriter (sb);

            writer.WriteArrayStart ();
            writer.Write ("like a lizard on a window pane");
            writer.WriteArrayEnd ();

            Assert.AreEqual (sb.ToString (),
                             "[\"like a lizard on a window pane\"]");
        }
开发者ID:kvantetore,项目名称:litjson,代码行数:12,代码来源:JsonWriterTest.cs

示例11: DumpJson

 public void DumpJson(JsonWriter w)
 {
     w.WriteObjectStart();
     w.WritePropertyName("id");
     w.Write(m_module_id);
     w.WritePropertyName("name");
     w.Write(m_module_name);
     w.WritePropertyName("method");
     w.Write(m_method);
     w.WritePropertyName("ajax_url");
     w.Write(m_ajax_url);
     w.WritePropertyName("post_url");
     w.Write(m_post_url);
     w.WritePropertyName("param_prefix");
     w.Write(m_param_prefix);
     w.WritePropertyName("args");
     w.WriteNameValueCollection(m_args);
     w.WritePropertyName("params");
     w.WriteNameValueCollection(m_params);
     w.WriteObjectEnd();
 }
开发者ID:Cyberspace-Networks,项目名称:PeopleAggregator,代码行数:21,代码来源:RemoteWidget.cs

示例12: ToJson

        public string ToJson()
        {
            var jsWriter = new JsonWriter();
            jsWriter.WriteObjectStart();
            jsWriter.WritePropertyName("alg");
            jsWriter.Write(Algorithm.ToString());

            if (null != KeyUri)
            {
                switch (KeyFormat)
                {
                    case KeyFormat.Json:
                        jsWriter.WritePropertyName("jku");
                        break;
                    case KeyFormat.X509:
                        jsWriter.WritePropertyName("xku");
                        break;
                    case KeyFormat.Rfc4050:
                        jsWriter.WritePropertyName("xdu");
                        break;
                }
                jsWriter.Write(KeyUri.ToString());
            }

            if (false == string.IsNullOrEmpty(KeyId))
            {
                jsWriter.WritePropertyName("kid");
                jsWriter.Write(KeyId);
            }
            jsWriter.WriteObjectEnd();
            return jsWriter.ToString();
        }
开发者ID:holytshirt,项目名称:Jwt4Net,代码行数:32,代码来源:JsonWebTokenHeader.cs

示例13: NullTest

        public void NullTest()
        {
            JsonWriter writer = new JsonWriter ();

            writer.WriteArrayStart ();
            writer.Write (null);
            writer.WriteArrayEnd ();
        }
开发者ID:kvantetore,项目名称:litjson,代码行数:8,代码来源:JsonWriterTest.cs

示例14: NestedObjectsTest

        public void NestedObjectsTest()
        {
            JsonWriter writer = new JsonWriter ();

            string json = "{\"book\":{\"title\":" +
                "\"Structure and Interpretation of Computer Programs\"," +
                "\"details\":{\"pages\":657}}}";

            writer.WriteObjectStart ();
            writer.WritePropertyName ("book");
            writer.WriteObjectStart ();
            writer.WritePropertyName ("title");
            writer.Write (
                "Structure and Interpretation of Computer Programs");
            writer.WritePropertyName ("details");
            writer.WriteObjectStart ();
            writer.WritePropertyName ("pages");
            writer.Write (657);
            writer.WriteObjectEnd ();
            writer.WriteObjectEnd ();
            writer.WriteObjectEnd ();

            Assert.AreEqual (writer.ToString (), json);
        }
开发者ID:kvantetore,项目名称:litjson,代码行数:24,代码来源:JsonWriterTest.cs

示例15: NestedArraysTest

        public void NestedArraysTest()
        {
            JsonWriter writer = new JsonWriter ();

            string json = "[1,[\"a\",\"b\",\"c\"],2,[[null]],3]";

            writer.WriteArrayStart ();
            writer.Write (1);
            writer.WriteArrayStart ();
            writer.Write ("a");
            writer.Write ("b");
            writer.Write ("c");
            writer.WriteArrayEnd ();
            writer.Write (2);
            writer.WriteArrayStart ();
            writer.WriteArrayStart ();
            writer.Write (null);
            writer.WriteArrayEnd ();
            writer.WriteArrayEnd ();
            writer.Write (3);
            writer.WriteArrayEnd ();

            Assert.AreEqual (writer.ToString (), json);
        }
开发者ID:kvantetore,项目名称:litjson,代码行数:24,代码来源:JsonWriterTest.cs


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