Exemplo n.º 1
0
 public JsonWriterArgs(ServiceContainer provider, TextWriter writer, JsonBuilderSettings settings)
 {
     WriterContainer        = provider;
     FormatDate             = (settings & JsonBuilderSettings.FormatDate) != 0;
     FormatTime             = (settings & JsonBuilderSettings.FormatTime) != 0;
     SerializableField      = (settings & JsonBuilderSettings.SerializableField) != 0;
     QuotWrapNumber         = (settings & JsonBuilderSettings.QuotWrapNumber) != 0;
     BooleanToNumber        = (settings & JsonBuilderSettings.BooleanToNumber) != 0;
     EnumToNumber           = (settings & JsonBuilderSettings.EnumToNumber) != 0;
     CheckLoopRef           = (settings & JsonBuilderSettings.CheckLoopRef) != 0;
     IgnoreEmptyTime        = (settings & JsonBuilderSettings.IgnoreEmptyTime) != 0;
     QuotWrapBoolean        = (settings & JsonBuilderSettings.QuotWrapBoolean) != 0;
     IgnoreNullMember       = (settings & JsonBuilderSettings.IgnoreNullMember) != 0;
     SerializableType       = (settings & JsonBuilderSettings.SerializableType) != 0;
     FormatAllMember        = (settings & JsonBuilderSettings.FormatAllMember) != 0;
     FilterSpecialCharacter = (settings & JsonBuilderSettings.FilterSpecialCharacter) != 0;
     CastUnicode            = (settings & JsonBuilderSettings.CastUnicode) != 0;
     GuidToUpper            = (settings & JsonBuilderSettings.GuidToUpper) != 0;
     GuidFormatString       = (settings & JsonBuilderSettings.GuidHasHyphens) != 0 ? "D" : "N";
     Writer = writer;
     Depth  = 0;
     if (CheckLoopRef)
     {
         _loopObject = new ArrayList(32);
     }
 }
Exemplo n.º 2
0
 public JsonBuilder(JsonBuilderSettings settings)
 {
     FormatDate        = (settings & JsonBuilderSettings.FormatDate) != 0;
     FormatTime        = (settings & JsonBuilderSettings.FormatTime) != 0;
     SerializableField = (settings & JsonBuilderSettings.SerializableField) != 0;
     QuotWrapNumber    = (settings & JsonBuilderSettings.QuotWrapNumber) != 0;
     BooleanToNumber   = (settings & JsonBuilderSettings.BooleanToNumber) != 0;
     EnumToNumber      = (settings & JsonBuilderSettings.EnumToNumber) != 0;
     CheckLoopRef      = (settings & JsonBuilderSettings.CheckLoopRef) != 0;
     IgnoreEmptyTime   = (settings & JsonBuilderSettings.IgnoreEmptyTime) != 0;
     QuotWrapBoolean   = (settings & JsonBuilderSettings.QuotWrapBoolean) != 0;
     IgnoreNullMember  = (settings & JsonBuilderSettings.IgnoreNullMember) != 0;
 }
Exemplo n.º 3
0
 /// <summary>
 /// 将对象转换为Json字符串
 /// </summary>
 /// <param name="obj"> </param>
 /// <param name="settings"> 序列化Json字符串时使用的设置参数 </param>
 public static string ToJsonString(this object obj, JsonBuilderSettings settings)
 {
     using (var buffer = new QuickStringWriter(4096))
     {
         var args = new JsonWriterArgs(WriterContainer, buffer, settings);
         if (obj == null || obj is DBNull)
         {
             WriterContainer.GetNullWriter().Write(null, args);
             return(buffer.ToString());
         }
         var writer = WriterContainer.GetWriter(obj.GetType());
         writer.Write(obj, args);
         return(buffer.ToString());
     }
 }
Exemplo n.º 4
0
 /// <summary> 将对象转换为Json字符串
 /// </summary>
 /// <param name="obj"></param>
 /// <param name="settings">序列化Json字符串时使用的设置参数</param>
 public static string ToJsonString(object obj, JsonBuilderSettings settings)
 {
     return(new QuickJsonBuilder(settings).ToJsonString(obj));
 }
Exemplo n.º 5
0
 public QuickJsonBuilder(JsonBuilderSettings settings)
     : base(settings)
 {
 }