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
16
17#ifndef Foundation_JSONString_INCLUDED
18#define Foundation_JSONString_INCLUDED
19
20
21#include "Poco/Foundation.h"
22
23
24namespace Poco {
25
26
27enum JSONOptions
28{
29 JSON_PRESERVE_KEY_ORDER = 1,
30 /// Applies to JSON::Object. If specified, the Object will
31 /// preserve the items insertion order. Otherwise, items
32 /// will be sorted by keys.
33 ///
34 /// Has no effect on toJSON() function.
35
36 JSON_ESCAPE_UNICODE = 2,
37 /// If specified, when the object is stringified, all
38 /// unicode characters will be escaped in the resulting
39 /// string.
40
41 JSON_WRAP_STRINGS = 4
42 /// If specified, the object will preserve the items
43 /// insertion order. Otherwise, items will be sorted
44 /// by keys.
45};
46
47
48//@ deprecated
49void Foundation_API toJSON(const std::string& value, std::ostream& out, bool wrap = true);
50 /// Formats string value into the supplied output stream by
51 /// escaping control and ALL Unicode characters.
52 /// If wrap is true, the resulting string is enclosed in double quotes.
53 ///
54 /// This function is deprecated, please use
55 ///
56 /// void Poco::toJSON(const std::string&, std::ostream&, int)
57
58
59//@ deprecated
60std::string Foundation_API toJSON(const std::string& value, bool wrap = true);
61 /// Formats string value by escaping control and ALL Unicode characters.
62 /// If wrap is true, the resulting string is enclosed in double quotes
63 ///
64 /// Returns formatted string.
65 ///
66 /// This function is deprecated, please use
67 ///
68 /// std::string Poco::toJSON(const std::string&, int)
69
70
71void Foundation_API toJSON(const std::string& value, std::ostream& out, int options);
72 /// Formats string value into the supplied output stream by
73 /// escaping control characters.
74 /// If JSON_WRAP_STRINGS is in options, the resulting strings is enclosed in double quotes
75 /// If JSON_ESCAPE_UNICODE is in options, all unicode characters will be escaped, otherwise
76 /// only the compulsory ones.
77
78
79std::string Foundation_API toJSON(const std::string& value, int options);
80 /// Formats string value by escaping control characters.
81 /// If JSON_WRAP_STRINGS is in options, the resulting string is enclosed in double quotes
82 /// If JSON_ESCAPE_UNICODE is in options, all unicode characters will be escaped, otherwise
83 /// only the compulsory ones.
84 ///
85 /// Returns formatted string.
86 /// If escapeAllUnicode is true, all unicode characters will be escaped, otherwise only the compulsory ones.
87
88
89
90} // namespace Poco
91
92
93#endif // Foundation_JSONString_INCLUDED
94