poco/Foundation/include/Poco/JSONString.h

94 lines
2.6 KiB
C
Raw Normal View History

//
// JSONString.h
//
// Library: Foundation
// Package: Core
// Module: String
//
// JSONString utility functions.
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#ifndef Foundation_JSONString_INCLUDED
#define Foundation_JSONString_INCLUDED
#include "Poco/Foundation.h"
namespace Poco {
2018-02-09 01:42:30 +01:00
enum JSONOptions
{
JSON_PRESERVE_KEY_ORDER = 1,
2018-02-08 16:08:42 +01:00
/// Applies to JSON::Object. If specified, the Object will
/// preserve the items insertion order. Otherwise, items
/// will be sorted by keys.
///
/// Has no effect on toJSON() function.
2018-02-09 01:42:30 +01:00
JSON_ESCAPE_UNICODE = 2,
2018-02-08 16:08:42 +01:00
/// If specified, when the object is stringified, all
/// unicode characters will be escaped in the resulting
/// string.
2018-03-05 15:05:04 +01:00
JSON_WRAP_STRINGS = 4
2018-02-08 16:08:42 +01:00
/// If specified, the object will preserve the items
/// insertion order. Otherwise, items will be sorted
/// by keys.
};
2018-02-08 16:08:42 +01:00
2018-02-09 01:42:30 +01:00
//@ deprecated
void Foundation_API toJSON(const std::string& value, std::ostream& out, bool wrap = true);
/// Formats string value into the supplied output stream by
2018-02-08 16:08:42 +01:00
/// escaping control and ALL Unicode characters.
/// If wrap is true, the resulting string is enclosed in double quotes.
///
/// This function is deprecated, please use
///
/// void Poco::toJSON(const std::string&, std::ostream&, int)
2018-02-09 01:42:30 +01:00
//@ deprecated
std::string Foundation_API toJSON(const std::string& value, bool wrap = true);
2018-02-08 16:08:42 +01:00
/// Formats string value by escaping control and ALL Unicode characters.
/// If wrap is true, the resulting string is enclosed in double quotes
2018-02-08 16:08:42 +01:00
///
/// Returns formatted string.
///
/// This function is deprecated, please use
///
/// std::string Poco::toJSON(const std::string&, int)
2018-02-08 16:08:42 +01:00
2018-02-09 01:42:30 +01:00
void Foundation_API toJSON(const std::string& value, std::ostream& out, int options);
2018-02-08 16:08:42 +01:00
/// Formats string value into the supplied output stream by
/// escaping control characters.
/// If JSON_WRAP_STRINGS is in options, the resulting strings is enclosed in double quotes
/// If JSON_ESCAPE_UNICODE is in options, all unicode characters will be escaped, otherwise
/// only the compulsory ones.
2018-02-09 01:42:30 +01:00
std::string Foundation_API toJSON(const std::string& value, int options);
/// Formats string value by escaping control characters.
2018-02-08 16:08:42 +01:00
/// If JSON_WRAP_STRINGS is in options, the resulting string is enclosed in double quotes
/// If JSON_ESCAPE_UNICODE is in options, all unicode characters will be escaped, otherwise
/// only the compulsory ones.
///
/// Returns formatted string.
2018-02-08 16:08:42 +01:00
/// If escapeAllUnicode is true, all unicode characters will be escaped, otherwise only the compulsory ones.
} // namespace Poco
#endif // Foundation_JSONString_INCLUDED