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


C# JsonWriter.WriteObjectEnd方法代码示例

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


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

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

示例2: ErrorArrayClosingTest

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

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

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

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

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

示例6: ObjectTest

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

            string json = "{\"flavour\":\"strawberry\",\"color\":\"red\"," +
                "\"amount\":3}";

            writer.WriteObjectStart ();
            writer.WritePropertyName ("flavour");
            writer.Write ("strawberry");
            writer.WritePropertyName ("color");
            writer.Write ("red");
            writer.WritePropertyName ("amount");
            writer.Write (3);
            writer.WriteObjectEnd ();

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

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

示例8: ReadInto

        private void ReadInto(JsonReader reader, JsonWriter jsonWriter, bool firstLevel, out Type type, out IJsonRpcTypeResolver resolver)
        {
            type = null;
            resolver = null;

            while (reader.Read()) {
                if (reader.Token == JsonToken.PropertyName) {
                    string propertyName = (string)reader.Value;

                    if (firstLevel && propertyName == "$type") {
                        if (!reader.Read())
                            throw new FormatException();
                        if (reader.Token != JsonToken.String)
                            throw new FormatException();

                        string typeString = (string)reader.Value;

                        type = ResolveType(typeString, out resolver);
                        if (type == null)
                            throw new FormatException();
                    } else {
                        jsonWriter.WritePropertyName(propertyName);
                    }
                } else if (reader.Token == JsonToken.Boolean) {
                    jsonWriter.Write((bool)reader.Value);
                } else if (reader.Token == JsonToken.Int) {
                    jsonWriter.Write((int)reader.Value);
                } else if (reader.Token == JsonToken.Long) {
                    jsonWriter.Write((long)reader.Value);
                } else if (reader.Token == JsonToken.Double) {
                    jsonWriter.Write((double)reader.Value);
                } else if (reader.Token == JsonToken.String) {
                    jsonWriter.Write((string)reader.Value);
                } else if (reader.Token == JsonToken.Null) {
                    jsonWriter.Write(null);
                } else if (reader.Token == JsonToken.ArrayStart) {
                    jsonWriter.WriteArrayStart();

                    while (reader.Read()) {
                        Type dummyType;
                        IJsonRpcTypeResolver dummyResolver;
                        ReadInto(reader, jsonWriter, false, out dummyType, out dummyResolver);
                        if (reader.Token == JsonToken.ArrayEnd) {
                            jsonWriter.WriteArrayEnd();
                            break;
                        }
                    }
                } else if (reader.Token == JsonToken.ObjectEnd) {
                    jsonWriter.WriteObjectEnd();
                    break;
                }
            }
        }
开发者ID:ikvm,项目名称:cloudb,代码行数:53,代码来源:JsonRpcMessageSerializer.cs

示例9: JMap

        public static string JMap(Map m)
        {
            LitJson.JsonWriter js = new LitJson.JsonWriter();
            js.PrettyPrint = true;
            js.IndentValue = 2;
            js.WriteObjectStart();
            js.WritePropertyName("min");
            js.WriteObjectStart();
            js.WritePropertyName("x");
            js.Write(m.min.x);
            js.WritePropertyName("y");
            js.Write(m.min.y);
            js.WriteObjectEnd();
            js.WritePropertyName("max");
            js.WriteObjectStart();
            js.WritePropertyName("x");
            js.Write(m.max.x);
            js.WritePropertyName("y");
            js.Write(m.max.y);
            js.WriteObjectEnd();
            js.WritePropertyName("tiles");
            js.WriteArrayStart();
            List<Map.Tile> tiles = m.GetTiles();
            foreach(Map.Tile t in tiles) {
                js.WriteObjectStart();
                // Key
                js.WritePropertyName("key");
                js.WriteObjectStart();
                js.WritePropertyName("x");
                js.Write(t.hexCoord.x);
                js.WritePropertyName("y");
                js.Write (t.hexCoord.y);
                js.WriteObjectEnd();
                //End of Key
                // Value
                js.WritePropertyName("value");
                js.WriteObjectStart();
                js.WritePropertyName("tileType");
                js.Write(t.spriteType.ToString());
                js.WritePropertyName("penalty");
                js.Write(t.penalty.ToString());
                js.WritePropertyName("visibility");
                js.Write(t.visibility.ToString());
                js.WriteObjectEnd();
                // End of Value
                js.WriteObjectEnd();
            }
            js.WriteArrayEnd();
            js.WritePropertyName("towns");
            js.WriteArrayStart();
            List<Map.Town> towns = m.GetTowns();
            foreach (Map.Town t in towns) {
                js.WriteObjectStart();
                // Key
                js.WritePropertyName("key");
                js.WriteObjectStart();
                js.WritePropertyName("x");
                js.Write(t.hexCoord.x);
                js.WritePropertyName("y");
                js.Write (t.hexCoord.y);
                js.WriteObjectEnd();
                // End of Key
                // Value
                js.WritePropertyName("value");
                js.WriteObjectStart();
                js.WritePropertyName("playerSide");
                js.Write(t.team);
                js.WriteObjectEnd();
                // End of Value
                js.WriteObjectEnd();
            }
            js.WriteArrayEnd();

            // TODO Units

            js.WriteObjectEnd();
            return js.ToString();
        }
开发者ID:gizmo-mk0,项目名称:kartofwar-client,代码行数:78,代码来源:JSON.cs

示例10: GetSchedule

    public static string GetSchedule(IDbConnection db)
    {
        TimeSpan t = DateTime.UtcNow - new DateTime(1970, 1, 1);
        long today = (long)t.TotalSeconds;
        StringBuilder sb = new StringBuilder();
        LitJson.JsonWriter writer = new LitJson.JsonWriter(sb);
        writer.WriteObjectStart();
        writer.WritePropertyName("bookings");
        writer.WriteArrayStart();
        using (IDbCommand command = db.CreateCommand())
        {
            command.CommandText = "select id, day, [from], till,  _user, _meetingroom, users_notified, users_to_be_notified, users_checkedin from booking where day>= @Day order by day, [from]";
            IDbDataParameter p = command.CreateParameter();
            p.ParameterName = "@Day";
            p.Value = today;
            command.Parameters.Add(p);
            using (IDataReader reader = command.ExecuteReader())
            {
                while (reader.Read())
                {
                    new MeetingRoomBooking(reader).Write(writer);
                }
            }
        }
        writer.WriteArrayEnd();

        writer.WritePropertyName("rooms");
        writer.WriteObjectStart();
        List<MeetingRoom> MeetingRooms = new List<MeetingRoom>();
        MeetingRooms = MeetingRoom.List(db);
        foreach (MeetingRoom meetingRoom in MeetingRooms)
        {
            writer.WritePropertyName(meetingRoom.Id.ToString());
            meetingRoom.Write(writer);
        }
        writer.WriteObjectEnd();
        writer.WritePropertyName("users");
        writer.WriteObjectStart();
        List<User> Users = new List<User>();
        Users = User.list(db);
        foreach (User user in Users)
        {
            writer.WritePropertyName(user.Email);
            user.Write(writer);
        }
        writer.WriteObjectEnd();
        writer.WriteObjectEnd();
        return sb.ToString();
    }
开发者ID:rogerthat-platform,项目名称:rogerthat-api-dotnet,代码行数:49,代码来源:MeetingRoomBooking.cs

示例11: WriteResponse

 public void WriteResponse(string id, Response resp, Exception error, StreamWriter sw)
 {
     JsonWriter writer = new JsonWriter(sw);
     writer.WriteObjectStart();
     writer.WritePropertyName("id");
     writer.Write(id);
     if (error == null)
     {
         writer.WritePropertyName("error");
         writer.Write(null);
         writer.WritePropertyName("result");
         if (resp == null)
             writer.Write(null);
         else
             resp.Write(writer, false);
     }
     else
     {
         writer.WritePropertyName("result");
         writer.Write(null);
         writer.WritePropertyName("error");
         writer.Write(string.Format("{0}\n{1}", error.Message, error.StackTrace.ToString()));
     }
     writer.WriteObjectEnd();
 }
开发者ID:rogerthat-platform,项目名称:rogerthat-api-dotnet,代码行数:25,代码来源:CallbackApi.cs

示例12: ErrorPropertyExpectedTest

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

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

示例13: Serialize

        private void Serialize(Message message, JsonWriter writer, bool inStream)
        {
            if (!inStream) {
                writer.WriteObjectStart();
                writer.WritePropertyName("jsonrpc");
                writer.Write("1.0");
            }

            if (message.Attributes.Contains("id")) {
                writer.WritePropertyName("id");
                // TODO: we presume is a number castable to int4 ...
                writer.Write((int)message.Attributes["id"]);
            }

            if (message is MessageStream) {
                writer.WritePropertyName("stream");
                writer.WriteArrayStart();
                foreach (Message m in ((MessageStream)message)) {
                    Serialize(m, writer, true);
                }
                writer.WriteArrayEnd();
            } else if (message.MessageType == MessageType.Request) {
                writer.WritePropertyName("method");
                writer.Write(message.Name);
                writer.WritePropertyName("params");
                writer.WriteArrayStart();
                foreach (MessageArgument argument in message.Arguments) {
                    WriteValue(argument, writer);
                }
                writer.WriteArrayEnd();
            } else {
                writer.WritePropertyName("result");
                IList<MessageArgument> args = message.Arguments;
                if (args.Count == 0) {
                    writer.Write(null);
                } else if (args.Count == 1) {
                    if (message.HasError) {
                        writer.Write(null);
                        writer.WritePropertyName("error");
                        writer.WriteObjectStart();
                        writer.WritePropertyName("message");
                        writer.Write(message.ErrorMessage);
                        writer.WritePropertyName("source");
                        writer.Write(message.Error.Source);
                        writer.WritePropertyName("stackTrace");
                        //TODO: does the string needs to be normalized?
                        writer.Write(message.ErrorStackTrace);
                        writer.WriteObjectEnd();
                    } else {
                        WriteValue(args[0], writer);
                        writer.WritePropertyName("error");
                        writer.Write(null);
                    }
                } else {
                    // here we are sure we don't have an error, so skip
                    // any check about it
                    writer.WriteArrayStart();
                    foreach (MessageArgument argument in message.Arguments) {
                        WriteValue(argument, writer);
                    }
                    writer.WriteArrayEnd();
                }
            }

            if (!inStream)
                writer.WriteObjectEnd();
        }
开发者ID:ikvm,项目名称:cloudb,代码行数:67,代码来源:JsonRpcMessageSerializer.cs

示例14: UpdateIssue

        public void UpdateIssue(IssueUpdate update, NetworkCredential credential,
            Action<string> stdout, Action<string> stderr)
        {
            var client = new WebClient();
            client.Headers.Add("Content-Type", "application/json");
            client.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(Encoding.UTF8.GetBytes(credential.UserName + ":" + credential.Password)));

            var jsonRPCQuery = new JsonWriter();
            jsonRPCQuery.WriteObjectStart();
            jsonRPCQuery.WritePropertyName("method");
            jsonRPCQuery.Write("ticket.update");
            jsonRPCQuery.WritePropertyName("params");
            jsonRPCQuery.WriteArrayStart();
            jsonRPCQuery.Write(update.Issue.Id);
            jsonRPCQuery.Write(update.Comment);
            jsonRPCQuery.WriteObjectStart();
            jsonRPCQuery.WritePropertyName("action");
            jsonRPCQuery.Write("resolve");
            jsonRPCQuery.WritePropertyName("action_resolve_resolve_resolution");
            jsonRPCQuery.Write("fixed");
            jsonRPCQuery.WriteObjectEnd();
            jsonRPCQuery.Write(true);
            jsonRPCQuery.WriteArrayEnd();
            jsonRPCQuery.WriteObjectEnd();

            client.UploadString(this.RPCUrl(), jsonRPCQuery.ToString());
        }
开发者ID:csware,项目名称:GurtleReloaded,代码行数:27,代码来源:TracProject.cs

示例15: PrettyPrintTest

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

            string json = @"
            [
            {
            ""precision"" : ""zip"",
            ""Latitude""  : 37.7668,
            ""Longitude"" : -122.3959,
            ""City""      : ""SAN FRANCISCO""
            },
              {
            ""precision"" : ""zip"",
            ""Latitude""  : 37.371991,
            ""Longitude"" : -122.02602,
            ""City""      : ""SUNNYVALE""
              }
            ]";

            writer.PrettyPrint = true;

            writer.WriteArrayStart ();
            writer.WriteObjectStart ();
            writer.WritePropertyName ("precision");
            writer.Write ("zip");
            writer.WritePropertyName ("Latitude");
            writer.Write (37.7668);
            writer.WritePropertyName ("Longitude");
            writer.Write (-122.3959);
            writer.WritePropertyName ("City");
            writer.Write ("SAN FRANCISCO");
            writer.WriteObjectEnd ();

            writer.IndentValue = 2;

            writer.WriteObjectStart ();
            writer.WritePropertyName ("precision");
            writer.Write ("zip");
            writer.WritePropertyName ("Latitude");
            writer.Write (37.371991);
            writer.WritePropertyName ("Longitude");
            writer.Write (-122.02602);
            writer.WritePropertyName ("City");
            writer.Write ("SUNNYVALE");
            writer.WriteObjectEnd ();
            writer.WriteArrayEnd ();

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


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