• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# LitJson.JsonWriter类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



JsonWriter类属于LitJson命名空间,在下文中一共展示了JsonWriter类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: createResource

        public static void createResource()
        {
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            DirectoryInfo di = new DirectoryInfo(Global.PATH + "/res");
            var jd = new LitJson.JsonData();
            FileInfo[] fs = di.GetFiles("*", SearchOption.TopDirectoryOnly);

            foreach (FileInfo fi in fs)
            {
                if (fi.Name.Contains(".manifest"))
                {
                    continue;
                }

                string pPath = "res/" + fi.Name;
                jd[pPath.Replace("/", "@").Replace("\\", "@")] = pPath;
            }


            getJsonData(jd,"");
            JsonWriter writer = new JsonWriter(sb);
            writer.PrettyPrint = true;
            writer.IndentValue = 4;
            jd.ToJson(writer);
             
            

 
            string result = CoccosHelper.Properties.Resources.tpl.Replace("#1#", sb.ToString());
            File.WriteAllText(Global.PATH + "/src/resource.js", result);

        }
开发者ID:wshxbqq,项目名称:Cocos2dxJs-Helper,代码行数:32,代码来源:Resource.cs


示例2: Encode

        public string Encode(object obj)
        {
            JsonWriter writer = new JsonWriter();
            JsonMapper.ToJson(obj, writer);

            return writer.ToString();
        }
开发者ID:ideadreamDefy,项目名称:Defy,代码行数:7,代码来源:LitJsonEncoder.cs


示例3: Write

 static void Write(JsonWriter writer, string failedMessage)
 {
     WriteObject(writer, () =>
         {
             WriteProperty(writer, "message", failedMessage);
         });
 }
开发者ID:dwhelan,项目名称:Cuke4Nuke,代码行数:7,代码来源:Formatter.cs


示例4: ExportJson

 public override void ExportJson(JsonWriter writer)
 {
     using (var scope = new JsonScopeObjectWriter(writer)) {
         WriteCommonObjectNode(writer, scope);
         scope.WriteKeyValue("color", Color);
         scope.WriteKeyValue("intensity", Intensity);
     }
 }
开发者ID:GTAWWEKID,项目名称:unity-scene-web-exporter,代码行数:8,代码来源:AmbientLightElem.cs


示例5: ExportJson

 public override void ExportJson(JsonWriter writer)
 {
     using (var scope = new JsonScopeObjectWriter(writer)) {
         WriteCommonObjectNode(writer, scope);
         scope.WriteKeyValue("geometry", Geometry.Uuid);
         scope.WriteKeyValue("material", Material.Uuid);
     }
 }
开发者ID:GTAWWEKID,项目名称:unity-scene-web-exporter,代码行数:8,代码来源:MeshElem.cs


示例6: ErrorPropertyExpectedTest

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

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


示例7: ExportJson

 public override void ExportJson(JsonWriter writer)
 {
     using (var scope = new JsonScopeObjectWriter(writer)) {
         scope.WriteKeyValue("url", "./" + Name);
         scope.WriteKeyValue("uuid", Uuid);
         scope.WriteKeyValue("name", Name);
     }
 }
开发者ID:GTAWWEKID,项目名称:unity-scene-web-exporter,代码行数:8,代码来源:ImageElem.cs


示例8: ErrorArrayClosingTest

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

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


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


示例10: ErrorExcessDataTest

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

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


示例11: SaveSettings

		public void SaveSettings(Settings.SerializedForm serializedForm) {
			JsonWriter writer = new JsonWriter();
			writer.PrettyPrint = true;
			JsonMapper.ToJson(serializedForm, writer);
			string json = writer.ToString();
			StreamWriter sr = new StreamWriter(this.configFile);
			sr.Write(json);
			sr.Close();
		}
开发者ID:modulexcite,项目名称:timer,代码行数:9,代码来源:FileHandler.cs


示例12: SaveTasks

		public void SaveTasks(TaskList.SerializedForm serializedForm) {
			JsonWriter writer = new JsonWriter();
			writer.PrettyPrint = true;
			JsonMapper.ToJson(serializedForm, writer);
			string json = writer.ToString();
			StreamWriter sr = new StreamWriter(this.taskFile);
			sr.Write(json);
			sr.Close();
		}
开发者ID:modulexcite,项目名称:timer,代码行数:9,代码来源:FileHandler.cs


示例13: ErrorObjectClosingTest

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

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


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


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


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


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


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


示例19: ProcessRequest

        public void ProcessRequest(HttpContext context)
        {
            HttpRequest request = context.Request;
            HttpResponse response = context.Response;

            // Validate incoming request
            if (request.HttpMethod != "POST")
            {
                response.StatusCode = 405;
                response.StatusDescription = "Method not allowed";
                response.End();
                return;
            }
            if (request.Headers["X-Nuntiuz-Service-Key"] != sikey)
            {
                response.StatusCode = 401;
                response.StatusDescription = "Not authorized";
                response.End();
                return;
            }
            if (!request.ContentType.StartsWith("application/json-rpc"))
            {
                response.StatusCode = 400;
                response.StatusDescription = "Bad request";
                response.End();
                return;
            }

            string id = null;
            string method = null;
            IDictionary<string, object> parameters = null;

            // parse request with culter en-US for safe JSON parsing
            CultureInfo serverCulture = Thread.CurrentThread.CurrentCulture;
            CultureInfo usCulture = new CultureInfo("en-US");
            Thread.CurrentThread.CurrentCulture = usCulture;
            try
            {
                try
                {
                    IDictionary<String, object> jsonRpcData = ReadJsonRpcData(request.InputStream);
                    id = (string)jsonRpcData["id"];
                    method = (string)jsonRpcData["method"];
                    parameters = (IDictionary<string, object>)jsonRpcData["parameters"];
                }
                catch (Exception e)
                {
                    using (StreamWriter sw = new StreamWriter(response.OutputStream))
                    {
                        JsonWriter writer = new JsonWriter(sw);
                        writer.WriteObjectStart();
                        writer.WritePropertyName("id");
                        writer.Write(id);
                        writer.WritePropertyName("result");
                        writer.Write(null);
                        writer.WritePropertyName("error");
                        writer.Write(string.Format("{0}\n{1}", e.Message, e.StackTrace.ToString()));
                        writer.WriteObjectEnd();
                    }
                    response.ContentType = "application/json-rpc";
                    response.StatusCode = 200;
                    response.End();
                    return;
                }
            }
            finally
            {
                Thread.CurrentThread.CurrentCulture = serverCulture;
            }

            Exception error = null;
            Response resp = null;
            try
            {
                resp = ExecuteMethod(method, parameters);
            }
            catch (Exception exception)
            {
                error = exception;
            }

            Thread.CurrentThread.CurrentCulture = usCulture;
            try
            {
                using (StreamWriter sw = new StreamWriter(response.OutputStream))
                {
                    WriteResponse(id, resp, error, sw);
                }
            }
            finally
            {
                Thread.CurrentThread.CurrentCulture = serverCulture;
            }

            response.ContentType = "application/json-rpc";
            response.StatusCode = 200;
            response.End();
        }
开发者ID:rogerthat-platform,项目名称:rogerthat-api-dotnet,代码行数:98,代码来源:CallbackApi.cs


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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# LitJson.WriterContext类代码示例发布时间:2022-05-26
下一篇:
C# LitJson.JsonReader类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap