IJsonWriter.cs 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. // JsonKit v0.5 - A simple but flexible Json library in a single .cs file.
  2. //
  3. // Copyright (C) 2014 Topten Software (contact@toptensoftware.com) All rights reserved.
  4. //
  5. // Licensed under the Apache License, Version 2.0 (the "License"); you may not use this product
  6. // except in compliance with the License. You may obtain a copy of the License at
  7. //
  8. // http://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software distributed under the
  11. // License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
  12. // either express or implied. See the License for the specific language governing permissions
  13. // and limitations under the License.
  14. using System;
  15. using System.Reflection;
  16. namespace Topten.JsonKit
  17. {
  18. /// <summary>
  19. /// Writes to a JSON output stream
  20. /// </summary>
  21. [Obfuscation(Exclude = true, ApplyToMembers = true)]
  22. public interface IJsonWriter
  23. {
  24. /// <summary>
  25. /// Writes a string literal
  26. /// </summary>
  27. /// <param name="str">The string to write</param>
  28. void WriteStringLiteral(string str);
  29. /// <summary>
  30. /// Write raw characters to the output stream
  31. /// </summary>
  32. /// <param name="str">The string to write</param>
  33. void WriteRaw(string str);
  34. /// <summary>
  35. /// Writes array delimeters to the output stream
  36. /// </summary>
  37. /// <param name="callback">A callback that should write the array elements</param>
  38. void WriteArray(Action callback);
  39. /// <summary>
  40. /// Writes dictionary delimeters to the output stream
  41. /// </summary>
  42. /// <param name="callback">A callback that should write the dictionary keys and values</param>
  43. void WriteDictionary(Action callback);
  44. /// <summary>
  45. /// Writes a value to the output stream
  46. /// </summary>
  47. /// <param name="value">The value to write</param>
  48. void WriteValue(object value);
  49. /// <summary>
  50. /// Writes the separator between array elements
  51. /// </summary>
  52. void WriteElement();
  53. /// <summary>
  54. /// Writes a dictionary key to the output stream
  55. /// </summary>
  56. void WriteKey(string key);
  57. /// <summary>
  58. /// Writes a dictionary key to the output stream without escaping the key
  59. /// </summary>
  60. void WriteKeyNoEscaping(string key);
  61. }
  62. }