Disable Formatting.Indented on specific fields

Nov 18, 2011 at 3:57 PM
Edited Nov 18, 2011 at 3:59 PM
Hi,
I'm using Json.Net to serialize a quite complex class. 
 One of its inner classes have many different List<double> with a lot of elements (about 50K number for each list).
Is is possibile to disable Formatting.Idented on this specific fields? I don't want a new line for each number of this lists...
Regards
Nov 22, 2011 at 1:29 PM
Edited Nov 22, 2011 at 1:30 PM

That's what I ended to do:

 public class DisableFormatting : JsonConverter
 {
     public override bool CanRead
     {
         get { return false; }
     }

     public override bool CanWrite
     {
         get { return true; }
     }

     public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
     {
         throw new NotSupportedException();
     }

     public override bool CanConvert(Type objectType)
     {
         return true;
     }

     public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
     {
         string json = JsonConvert.SerializeObject(value);
         writer.WriteRawValue(json);
     }
 }

Usage:

[JsonConverter(typeof(DisableFormatting))]
public List<double> Vertices { get; private set; }