AWS SDK for C++

AWS SDK for C++ Version 1.11.440

Loading...
Searching...
No Matches
JsonSerializer.h
1
6#pragma once
7
8#include <aws/core/Core_EXPORTS.h>
9
10#include <aws/core/utils/Array.h>
11#include <aws/core/utils/memory/stl/AWSStreamFwd.h>
12#include <aws/core/utils/memory/stl/AWSString.h>
13#include <aws/core/utils/memory/stl/AWSMap.h>
14#include <aws/core/external/cjson/cJSON.h>
15
16#include <utility>
17
18namespace Aws
19{
20 namespace Utils
21 {
22 class Document;
23 class DocumentView;
24
25 namespace Json
26 {
27 class JsonView;
32 class AWS_CORE_API JsonValue
33 {
34 public:
39
43 JsonValue(const Aws::String& value);
44
49
54 JsonValue(const JsonValue& value);
55
61
66
68
73
82
87
88 bool operator==(const JsonValue& other) const;
89 bool operator!=(const JsonValue& other) const;
90
94 JsonValue& WithString(const Aws::String& key, const Aws::String& value);
95 JsonValue& WithString(const char* key, const Aws::String& value);
96
101
105 JsonValue& WithBool(const Aws::String& key, bool value);
106 JsonValue& WithBool(const char* key, bool value);
107
111 JsonValue& AsBool(bool value);
112
116 JsonValue& WithInteger(const Aws::String& key, int value);
117 JsonValue& WithInteger(const char* key, int value);
118
122 JsonValue& AsInteger(int value);
123
127 JsonValue& WithInt64(const Aws::String& key, long long value);
128 JsonValue& WithInt64(const char* key, long long value);
129
133 JsonValue& AsInt64(long long value);
134
138 JsonValue& WithDouble(const Aws::String& key, double value);
139 JsonValue& WithDouble(const char* key, double value);
140
144 JsonValue& AsDouble(double value);
145
150 JsonValue& WithArray(const char* key, const Array<Aws::String>& array);
151
157
163
168
173
178 JsonValue& WithObject(const Aws::String& key, const JsonValue& value);
179 JsonValue& WithObject(const char* key, const JsonValue& value);
180
185 JsonValue& WithObject(const char* key, JsonValue&& value);
186
191
196
201 inline bool WasParseSuccessful() const
202 {
203 return m_wasParseSuccessful;
204 }
205
209 inline const Aws::String& GetErrorMessage() const
210 {
211 return m_errorMessage;
212 }
213
217 JsonView View() const;
218
219 private:
220 void Destroy();
221 JsonValue(cJSON* value);
222 cJSON* m_value;
223 bool m_wasParseSuccessful;
224 Aws::String m_errorMessage;
225 friend class JsonView;
226 };
227
234 class AWS_CORE_API JsonView
235 {
236 public:
237 /* constructors */
241
246
252
256 bool GetBool(const Aws::String& key) const;
257
261 bool AsBool() const;
262
267 int GetInteger(const Aws::String& key) const;
268
272 int AsInteger() const;
273
278 int64_t GetInt64(const Aws::String& key) const;
279
283 int64_t AsInt64() const;
284
288 double GetDouble(const Aws::String& key) const;
289
293 double AsDouble() const;
294
299
304
308 JsonView GetObject(const Aws::String& key) const;
309
314
320
325 bool ValueExists(const Aws::String& key) const;
326
330 bool KeyExists(const Aws::String& key) const;
331
335 bool IsObject() const;
336
340 bool IsBool() const;
341
345 bool IsString() const;
346
351 bool IsIntegerType() const;
352
357
361 bool IsListType() const;
362
366 bool IsNull() const;
367
372 Aws::String WriteCompact(bool treatAsObject = true) const;
373
378 Aws::String WriteReadable(bool treatAsObject = true) const;
379
384
385 private:
386 JsonView(cJSON* val);
387 JsonView& operator=(cJSON* val);
388 cJSON* m_value;
390 };
391
392 } // namespace Json
393 } // namespace Utils
394} // namespace Aws
395
JsonValue & WithArray(const Aws::String &key, Array< JsonValue > &&array)
JsonValue & AsArray(Array< JsonValue > &&array)
JsonValue & WithObject(const char *key, const JsonValue &value)
JsonValue & WithInteger(const Aws::String &key, int value)
const Aws::String & GetErrorMessage() const
JsonValue & WithDouble(const char *key, double value)
JsonValue & WithDouble(const Aws::String &key, double value)
JsonValue & operator=(const Aws::Utils::DocumentView &value)
JsonValue & AsObject(const JsonValue &value)
JsonValue(const Aws::Utils::DocumentView &value)
JsonValue & WithBool(const Aws::String &key, bool value)
JsonValue & WithBool(const char *key, bool value)
JsonValue & WithObject(const char *key, JsonValue &&value)
JsonValue & AsInteger(int value)
JsonValue & AsString(const Aws::String &value)
bool operator!=(const JsonValue &other) const
JsonValue & WithArray(const Aws::String &key, const Array< Aws::String > &array)
bool operator==(const JsonValue &other) const
JsonValue & WithString(const Aws::String &key, const Aws::String &value)
JsonValue & WithArray(const char *key, const Array< Aws::String > &array)
JsonValue & WithInt64(const Aws::String &key, long long value)
JsonValue & operator=(const JsonValue &other)
JsonValue & WithArray(const Aws::String &key, const Array< JsonValue > &array)
JsonValue & AsDouble(double value)
JsonValue & AsObject(JsonValue &&value)
JsonValue(const Aws::String &value)
JsonValue & WithObject(const Aws::String &key, JsonValue &&value)
JsonValue & operator=(JsonValue &&other)
JsonValue & AsArray(const Array< JsonValue > &array)
JsonValue & WithString(const char *key, const Aws::String &value)
JsonValue(JsonValue &&value)
JsonValue & WithInteger(const char *key, int value)
JsonValue & AsInt64(long long value)
JsonValue(const JsonValue &value)
JsonValue & WithInt64(const char *key, long long value)
JsonValue & AsBool(bool value)
JsonValue & WithObject(const Aws::String &key, const JsonValue &value)
JsonValue(Aws::IStream &istream)
bool ValueExists(const Aws::String &key) const
JsonView(const JsonValue &v)
bool IsFloatingPointType() const
double GetDouble(const Aws::String &key) const
Aws::String WriteCompact(bool treatAsObject=true) const
Aws::String AsString() const
bool GetBool(const Aws::String &key) const
int64_t GetInt64(const Aws::String &key) const
JsonView GetObject(const Aws::String &key) const
Aws::String WriteReadable(bool treatAsObject=true) const
JsonView AsObject() const
Aws::String GetString(const Aws::String &key) const
Aws::Map< Aws::String, JsonView > GetAllObjects() const
bool KeyExists(const Aws::String &key) const
Array< JsonView > GetArray(const Aws::String &key) const
JsonView & operator=(const JsonValue &v)
Array< JsonView > AsArray() const
int GetInteger(const Aws::String &key) const
JsonValue Materialize() const
std::map< K, V, std::less< K >, Aws::Allocator< std::pair< const K, V > > > Map
Definition AWSMap.h:20
std::basic_istream< char, std::char_traits< char > > IStream
std::basic_string< char, std::char_traits< char >, Aws::Allocator< char > > String
Definition AWSString.h:97
Definition cJSON.h:115