JSONString.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. //
  2. // JSONString.h
  3. //
  4. // Library: Foundation
  5. // Package: Core
  6. // Module: String
  7. //
  8. // JSONString utility functions.
  9. //
  10. // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
  11. // and Contributors.
  12. //
  13. // SPDX-License-Identifier: BSL-1.0
  14. //
  15. #ifndef Foundation_JSONString_INCLUDED
  16. #define Foundation_JSONString_INCLUDED
  17. #include "Poco/Foundation.h"
  18. namespace Poco {
  19. enum JSONOptions
  20. {
  21. JSON_PRESERVE_KEY_ORDER = 1,
  22. /// Applies to JSON::Object. If specified, the Object will
  23. /// preserve the items insertion order. Otherwise, items
  24. /// will be sorted by keys.
  25. ///
  26. /// Has no effect on toJSON() function.
  27. JSON_ESCAPE_UNICODE = 2,
  28. /// If specified, when the object is stringified, all
  29. /// unicode characters will be escaped in the resulting
  30. /// string.
  31. JSON_WRAP_STRINGS = 4
  32. /// If specified, the object will preserve the items
  33. /// insertion order. Otherwise, items will be sorted
  34. /// by keys.
  35. };
  36. //@ deprecated
  37. void Foundation_API toJSON(const std::string& value, std::ostream& out, bool wrap = true);
  38. /// Formats string value into the supplied output stream by
  39. /// escaping control and ALL Unicode characters.
  40. /// If wrap is true, the resulting string is enclosed in double quotes.
  41. ///
  42. /// This function is deprecated, please use
  43. ///
  44. /// void Poco::toJSON(const std::string&, std::ostream&, int)
  45. //@ deprecated
  46. std::string Foundation_API toJSON(const std::string& value, bool wrap = true);
  47. /// Formats string value by escaping control and ALL Unicode characters.
  48. /// If wrap is true, the resulting string is enclosed in double quotes
  49. ///
  50. /// Returns formatted string.
  51. ///
  52. /// This function is deprecated, please use
  53. ///
  54. /// std::string Poco::toJSON(const std::string&, int)
  55. void Foundation_API toJSON(const std::string& value, std::ostream& out, int options);
  56. /// Formats string value into the supplied output stream by
  57. /// escaping control characters.
  58. /// If JSON_WRAP_STRINGS is in options, the resulting strings is enclosed in double quotes
  59. /// If JSON_ESCAPE_UNICODE is in options, all unicode characters will be escaped, otherwise
  60. /// only the compulsory ones.
  61. std::string Foundation_API toJSON(const std::string& value, int options);
  62. /// Formats string value by escaping control characters.
  63. /// If JSON_WRAP_STRINGS is in options, the resulting string is enclosed in double quotes
  64. /// If JSON_ESCAPE_UNICODE is in options, all unicode characters will be escaped, otherwise
  65. /// only the compulsory ones.
  66. ///
  67. /// Returns formatted string.
  68. /// If escapeAllUnicode is true, all unicode characters will be escaped, otherwise only the compulsory ones.
  69. } // namespace Poco
  70. #endif // Foundation_JSONString_INCLUDED