AWS SDK for C++

AWS SDK for C++ Version 1.11.788

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 JsonValue& WithNull(const char* key);
102
107
112
116 JsonValue& WithBool(const Aws::String& key, bool value);
117 JsonValue& WithBool(const char* key, bool value);
118
122 JsonValue& AsBool(bool value);
123
127 JsonValue& WithInteger(const Aws::String& key, int value);
128 JsonValue& WithInteger(const char* key, int value);
129
133 JsonValue& AsInteger(int value);
134
138 JsonValue& WithInt64(const Aws::String& key, long long value);
139 JsonValue& WithInt64(const char* key, long long value);
140
144 JsonValue& AsInt64(long long value);
145
149 JsonValue& WithDouble(const Aws::String& key, double value);
150 JsonValue& WithDouble(const char* key, double value);
151
155 JsonValue& AsDouble(double value);
156
161 JsonValue& WithArray(const char* key, const Array<Aws::String>& array);
162
168
174
179
184
189 JsonValue& WithObject(const Aws::String& key, const JsonValue& value);
190 JsonValue& WithObject(const char* key, const JsonValue& value);
191
196 JsonValue& WithObject(const char* key, JsonValue&& value);
197
202
207
212 inline bool WasParseSuccessful() const
213 {
214 return m_wasParseSuccessful;
215 }
216
220 inline const Aws::String& GetErrorMessage() const
221 {
222 return m_errorMessage;
223 }
224
228 JsonView View() const;
229
230 private:
231 void Destroy();
232 JsonValue(cJSON* value);
233 cJSON* m_value;
234 bool m_wasParseSuccessful;
235 Aws::String m_errorMessage;
236 friend class JsonView;
237 };
238
245 class AWS_CORE_API JsonView
246 {
247 public:
248 /* constructors */
252
257
263
267 bool GetBool(const Aws::String& key) const;
268
272 bool AsBool() const;
273
278 int GetInteger(const Aws::String& key) const;
279
283 int AsInteger() const;
284
289 int64_t GetInt64(const Aws::String& key) const;
290
294 int64_t AsInt64() const;
295
299 double GetDouble(const Aws::String& key) const;
300
304 double AsDouble() const;
305
310
315
319 JsonView GetObject(const Aws::String& key) const;
320
325
331
336 bool ValueExists(const Aws::String& key) const;
337
341 bool KeyExists(const Aws::String& key) const;
342
346 bool IsObject() const;
347
351 bool IsBool() const;
352
356 bool IsString() const;
357
362 bool IsIntegerType() const;
363
368
372 bool IsListType() const;
373
377 bool IsNull() const;
378
383 Aws::String WriteCompact(bool treatAsObject = true) const;
384
389 Aws::String WriteReadable(bool treatAsObject = true) const;
390
395
396 private:
397 JsonView(cJSON* val);
398 JsonView& operator=(cJSON* val);
399 cJSON* m_value;
401 };
402
403 } // namespace Json
404 } // namespace Utils
405} // namespace Aws
406
JsonValue & WithNull(const char *key)
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)
JsonValue & WithNull(const Aws::String &key)
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