/// <summary> /// Encode special chars. /// </summary> private static void EncodeEscaped() { FOA.Encoder encoder = new FOA.Encoder(); Console.WriteLine("Escape enabled:"); encoder.Write("a(b[c]d)e=f"); Console.Write(encoder.GetString()); Console.WriteLine("Escape disabled:"); encoder.SetOption(FOA.Option.EnableEscape, false); encoder.Write("a(b[c]d)e=f"); Console.Write(encoder.GetString()); }
/// <summary> /// Encode the data without using a backing store, that is, the encoded /// data is not appended to a stream. Instead only encoded data from the /// last Write() is stored in the buffer. /// </summary> private static void EncodeNoStore() { FOA.Encoder encoder = new FOA.Encoder(); encoder.Write("person", FOA.SpecialChars.StartObject); Console.Write(encoder.GetString()); encoder.Write("name", "Adam"); Console.Write(encoder.GetString()); encoder.Write("age", 35); Console.Write(encoder.GetString()); encoder.Write("ratio", 8.37); Console.Write(encoder.GetString()); encoder.Write(FOA.SpecialChars.EndObject); Console.Write(encoder.GetString()); }