CodePorting.Translator Cs2Cpp
CodePorting.Translator.Cs2Cpp.Framework
json_serializer_helpers.h
1#pragma once
2
3#include <system/type_info.h>
4#include <system/threading/cancellation_token.h>
5#include <system/span.h>
6#include <system/scope_guard.h>
7#include <system/object_ext.h>
8#include <system/nullable.h>
9#include <system/memory_extensions.h>
10#include <system/memory.h>
11#include <system/io/stream.h>
12#include <system/func.h>
13#include <system/exceptions.h>
14#include <system/details/stack_array.h>
15#include <system/details/patterns.h>
16#include <system/details/dispose_guard.h>
17#include <system/default.h>
18#include <system/collections/list.h>
19#include <system/collections/ienumerator.h>
20#include <system/buffers/array_pool.h>
21#include <system/array.h>
22#include <functional>
23#include <cstdint>
24
25#include "system/text/json/serialization/json_serializer_options.h"
26#include "system/text/json/throw_helper.h"
27#include "system/text/json/document/json_document.h"
28#include "system/text/json/document/json_element.h"
29#include "system/text/json/nodes/json_node.h"
30#include "system/text/json/reader/utf8_json_reader.h"
31#include "system/text/json/writer/utf8_json_writer.h"
32#include "system/text/json/json_encoded_text.h"
33#include "system/text/json/serialization/read_stack.h"
34#include "system/text/json/pooled_byte_buffer_writer.h"
35#include "system/text/json/writer/json_writer_options.h"
36#include "system/text/json/reader/json_reader_options.h"
37#include "system/text/json/json_comment_handling.h"
38#include "system/text/json/reader/json_reader_state.h"
39#include "system/text/json/json_exception.h"
40#include "system/text/json/json_constants.h"
41#include "system/text/json/reader/json_reader_helper.h"
42#include "system/text/json/serialization/stream_read_buffer_state.h"
43#include "system/text/json/writer/utf8_json_writer_cache.h"
44#include "system/text/json/document/json_document_options.h"
45#include "system/text/json/nodes/json_node_options.h"
46
47namespace System
48{
49namespace Text
50{
51namespace Json
52{
53class JsonElement;
54class JsonSerializerOptions;
55enum class MetadataPropertyName : uint8_t;
56namespace Serialization
57{
58namespace Converters
59{
60template <typename> class CastingConverter;
61class DefaultObjectConverter;
62template <typename, typename> class ListOfTConverter;
63template <typename> class ObjectDefaultConverter;
64template <typename> class ObjectWithParameterizedConstructorConverter;
65} // namespace Converters
66template <typename, typename> class JsonCollectionConverter;
67class JsonConverterBase;
68template <typename> class JsonConverter;
69template <typename...> class JsonDictionaryConverter;
70enum class JsonNumberHandling;
71class JsonSerializerContext;
72namespace Metadata
73{
74class JsonPolymorphismOptions;
75class JsonPropertyInfoBase;
76class PolymorphicTypeResolver;
77} // namespace Metadata
78} // namespace Serialization
79class WriteStack;
80} // namespace Json
81} // namespace Text
82} // namespace System
83
84namespace System {
85
86namespace Text {
87
88namespace Json {
89
91{
93
101 friend class ThrowHelper;
103 template<typename FT0, typename FT1> friend class System::Text::Json::Serialization::JsonCollectionConverter;
107 template<typename FT0> friend class System::Text::Json::Serialization::JsonConverter;
109public:
110
111 template<typename TValue>
113 {
114
115 if (System::IsNull(document))
116 {
117 throw System::ArgumentNullException(u"document");
118 }
119 if (System::IsNull(jsonTypeInfo))
120 {
121 throw System::ArgumentNullException(u"jsonTypeInfo");
122 }
123
124 jsonTypeInfo->EnsureConfigured();
125 ReadOnlySpan<uint8_t> utf8Json = document->GetRootRawValue().get_Span();
126 return ReadFromSpan<TValue>(utf8Json, jsonTypeInfo);
127 }
128
131 template<typename TValue>
133 {
134 if (System::IsNull(jsonTypeInfo))
135 {
136 throw System::ArgumentNullException(u"jsonTypeInfo");
137 }
138
139 jsonTypeInfo->EnsureConfigured();
140 ReadOnlySpan<uint8_t> utf8Json = element.GetRawValue().get_Span();
141 return ReadFromSpan<TValue>(utf8Json, jsonTypeInfo);
142 }
143
146 template<typename TValue>
148 {
149 if (System::IsNull(jsonTypeInfo))
150 {
151 throw System::ArgumentNullException(u"jsonTypeInfo");
152 }
153
154 jsonTypeInfo->EnsureConfigured();
155 return ReadFromNode<TValue>(node, jsonTypeInfo);
156 }
157
160 template<typename TValue>
162 {
163 if (System::IsNull(jsonTypeInfo))
164 {
165 throw System::ArgumentNullException(u"jsonTypeInfo");
166 }
167
168 jsonTypeInfo->EnsureConfigured();
169 return Read<TValue>(System::Ref(reader), jsonTypeInfo);
170 }
171
174 template<typename TValue>
176 {
177 if (System::IsNull(System::ExplicitCast<System::Object>(json)))
178 {
179 throw System::ArgumentNullException(u"json");
180 }
181 if (System::IsNull(jsonTypeInfo))
182 {
183 throw System::ArgumentNullException(u"jsonTypeInfo");
184 }
185
186 jsonTypeInfo->EnsureConfigured();
187 return ReadFromSpan<TValue>(MemoryExtensions::AsSpan(json), jsonTypeInfo);
188 }
189
190 template<typename TValue>
192 {
193 if (System::IsNull(jsonTypeInfo))
194 {
195 throw System::ArgumentNullException(u"jsonTypeInfo");
196 }
197
198 jsonTypeInfo->EnsureConfigured();
199 return ReadFromSpan<TValue>(json, jsonTypeInfo);
200 }
201
202 template<typename TValue>
204 {
205 if (System::IsNull(options))
206 {
207 throw System::ArgumentNullException(u"options");
208 }
209
210 return Deserialize<TValue>(json, options->template GetTypeInfo<TValue>());
211 }
212
217 template<typename TValue>
219 {
220 if (System::IsNull(utf8Json))
221 {
222 throw System::ArgumentNullException(u"utf8Json");
223 }
224 if (System::IsNull(jsonTypeInfo))
225 {
226 throw System::ArgumentNullException(u"jsonTypeInfo");
227 }
228
229 jsonTypeInfo->EnsureConfigured();
230 return jsonTypeInfo->Deserialize(utf8Json);
231 }
232
235 template<typename TValue>
237 {
238 if (System::IsNull(jsonTypeInfo))
239 {
240 throw System::ArgumentNullException(u"jsonTypeInfo");
241 }
242
243 jsonTypeInfo->EnsureConfigured();
244 return ReadFromSpan<TValue>(utf8Json, jsonTypeInfo);
245 }
246
249 template<typename TValue>
251 {
252 if (System::IsNull(writer))
253 {
254 throw System::ArgumentNullException(u"writer");
255 }
256 if (System::IsNull(jsonTypeInfo))
257 {
258 throw System::ArgumentNullException(u"jsonTypeInfo");
259 }
260
261 jsonTypeInfo->EnsureConfigured();
262 jsonTypeInfo->Serialize(writer, value);
263 }
264
267 template<typename TValue>
269 {
270 if (System::IsNull(utf8Json))
271 {
272 throw System::ArgumentNullException(u"utf8Json");
273 }
274 if (System::IsNull(jsonTypeInfo))
275 {
276 throw System::ArgumentNullException(u"jsonTypeInfo");
277 }
278
279 jsonTypeInfo->EnsureConfigured();
280 jsonTypeInfo->Serialize(utf8Json, value);
281 }
282
285 template<typename TValue>
287 {
288 if (System::IsNull(jsonTypeInfo))
289 {
290 throw System::ArgumentNullException(u"jsonTypeInfo");
291 }
292
293 jsonTypeInfo->EnsureConfigured();
294 return WriteString<TValue>(value, jsonTypeInfo);
295 }
296
297 template<typename TValue>
299 {
300 if (System::IsNull(options))
301 {
302 throw System::ArgumentNullException(u"options");
303 }
304
305 return Serialize<TValue>(value, options->template GetTypeInfo<TValue>());
306 }
307
310 template<typename TValue>
312 {
313 if (System::IsNull(jsonTypeInfo))
314 {
315 throw System::ArgumentNullException(u"jsonTypeInfo");
316 }
317
318 jsonTypeInfo->EnsureConfigured();
319 return WriteDocument<TValue>(value, jsonTypeInfo);
320 }
321
324 template<typename TValue>
326 {
327 if (System::IsNull(jsonTypeInfo))
328 {
329 throw System::ArgumentNullException(u"jsonTypeInfo");
330 }
331
332 jsonTypeInfo->EnsureConfigured();
333 return WriteNode<TValue>(value, jsonTypeInfo);
334 }
335
338 template<typename TValue>
340 {
341 if (System::IsNull(jsonTypeInfo))
342 {
343 throw System::ArgumentNullException(u"jsonTypeInfo");
344 }
345
346 jsonTypeInfo->EnsureConfigured();
347 return WriteElement<TValue>(value, jsonTypeInfo);
348 }
349
352 template<typename TValue>
354 {
355 if (System::IsNull(jsonTypeInfo))
356 {
357 throw System::ArgumentNullException(u"jsonTypeInfo");
358 }
359
360 jsonTypeInfo->EnsureConfigured();
361 return WriteBytes<TValue>(value, jsonTypeInfo);
362 }
363
366
367 static ASPOSECPP_SHARED_API const float FlushThreshold;
368
369protected:
370
377
378 static ASPOSECPP_SHARED_API bool IsValidNumberHandlingValue(Serialization::JsonNumberHandling handling);
379 template<typename T>
381 {
382 return Serialization::Details::UnboxOnRead<T>(value);
383 }
384
385 template<typename T>
387 {
388 return Serialization::Details::UnboxOnWrite<T>(value);
389 }
390
391public:
392
393 static ASPOSECPP_SHARED_API System::SharedPtr<Serialization::Metadata::JsonPropertyInfoBase> LookupProperty(System::SharedPtr<Object> obj, ReadOnlySpan<uint8_t> unescapedPropertyName, ReadStack& state, System::SharedPtr<JsonSerializerOptions> options, bool& useExtensionProperty, bool createExtensionProperty = true);
394 static ASPOSECPP_SHARED_API ReadOnlySpan<uint8_t> GetPropertyName(ReadStack& state, Utf8JsonReader& reader, System::SharedPtr<JsonSerializerOptions> options, bool& isAlreadyReadMetadataProperty);
399 static ASPOSECPP_SHARED_API void ValidateMetadataForObjectConverter(ReadStack& state);
403
404private:
405
406 static System::SharedPtr<Array<uint8_t>> s_typePropertyName;
407 static System::SharedPtr<Array<uint8_t>> s_valuesPropertyName;
408
410 static void ValidateInputType(System::SharedPtr<Object> value, const TypeInfo& inputType);
411 // Using statement is translated using System::Details::DisposeGuard class which may store exception and then throw from destructor.
412 // We block the warnings related as these are false alarms (the exception, if caught, will be re-thrown from the destructor).
413 #if defined(__MSVC__)
414 #pragma warning( push )
415 #pragma warning(disable : 4715)
416 #pragma warning(disable : 4700)
417 #pragma warning(disable : 4701)
418 #elif defined(__GNUC__)
419 #pragma GCC diagnostic push
420 #pragma GCC diagnostic ignored "-Wreturn-type"
421 #endif
422 template<typename TValue>
424 {
425 System::SharedPtr<JsonSerializerOptions> options = jsonTypeInfo->get_Options();
426
427 // For performance, share the same buffer across serialization and deserialization.
428 {
429 auto output = System::MakeObject<PooledByteBufferWriter>(options->get_DefaultBufferSize());
430 // Clearing resources under 'using' statement
431 System::Details::DisposeGuard<1> __dispose_guard_0({output});
432
433 try
434 {
435 {
436 auto writer = System::MakeObject<Utf8JsonWriter>(output, options->GetWriterOptions());
437 // Clearing resources under 'using' statement
438 System::Details::DisposeGuard<1> __dispose_guard_1({writer});
439
440 try
441 {
442 if (node == nullptr)
443 {
444 writer->WriteNullValue();
445 }
446 else
447 {
448 node->WriteTo(writer, options);
449 }
450 }
451 catch(...)
452 {
453 __dispose_guard_1.SetCurrentException(std::current_exception());
454 }
455 }
456 return ReadFromSpan<TValue>(output->get_WrittenSpan(), jsonTypeInfo);
457 }
458 catch(...)
459 {
460 __dispose_guard_0.SetCurrentException(std::current_exception());
461 }
462 }
463
464 }
465 #if defined(__MSVC__)
466 #pragma warning( pop )
467 #elif defined(__GNUC__)
468 #pragma GCC diagnostic pop
469 #endif
470
472 template<typename TValue>
473 static TValue Read(Utf8JsonReader& reader, System::SharedPtr<Serialization::Metadata::JsonTypeInfo<TValue>> jsonTypeInfo)
474 {
475
476 if (reader.get_CurrentState().get_Options().get_CommentHandling() == System::Text::Json::JsonCommentHandling::Allow)
477 {
479 }
480
481 ReadStack state = System::Default<System::Text::Json::ReadStack>();
482 state.Initialize(jsonTypeInfo);
483 Utf8JsonReader restore = reader;
484
485 try
486 {
487 Utf8JsonReader scopedReader = GetReaderScopedToNextValue(System::Ref(reader), System::Ref(state));
488 return jsonTypeInfo->Deserialize(System::Ref(scopedReader), System::Ref(state));
489 }
490 catch (JsonException& )
491 {
492 reader = restore;
493 throw;
494 }
495 }
496
497 static System::SharedPtr<Object> ReadAsObject(Utf8JsonReader& reader, System::SharedPtr<Serialization::Metadata::JsonTypeInfoBase> jsonTypeInfo);
498 static ASPOSECPP_SHARED_API Utf8JsonReader GetReaderScopedToNextValue(Utf8JsonReader& reader, ReadStack& state);
499 template<typename TValue>
500 static TValue ReadFromSpan(ReadOnlySpan<char16_t> json, System::SharedPtr<Serialization::Metadata::JsonTypeInfo<TValue>> jsonTypeInfo)
501 {
502
504
505 // For performance, avoid obtaining actual byte count unless memory usage is higher than the threshold.
506 System::Details::StackArray<uint8_t, System::Text::Json::JsonConstants::StackallocByteThreshold> array_0;
507 Span<uint8_t> utf8 = json.get_Length() <= (System::Text::Json::JsonConstants::StackallocByteThreshold / System::Text::Json::JsonConstants::MaxExpansionFactorWhileTranscoding) ? array_0 : Span<uint8_t>::to_Span(static_cast<int64_t>(json.get_Length()) <= (System::Text::Json::JsonConstants::ArrayPoolMaxSizeBeforeUsingNormalAlloc / static_cast<int64_t>(System::Text::Json::JsonConstants::MaxExpansionFactorWhileTranscoding)) ? tempArray = Buffers::ArrayPool<uint8_t>::get_Shared()->Rent(json.get_Length() * System::Text::Json::JsonConstants::MaxExpansionFactorWhileTranscoding) : System::MakeArray<uint8_t>(System::Text::Json::JsonReaderHelper::GetUtf8ByteCount(json), 0));
508
509 {
510 auto __finally_guard_0 = ::System::MakeScopeGuard([&utf8, &tempArray]()
511 {
512 if (!(tempArray == nullptr))
513 {
514 utf8.Clear();
515 Buffers::ArrayPool<uint8_t>::get_Shared()->Return(tempArray);
516 }
517 });
518
519 try
520 {
521 int32_t actualByteCount = System::Text::Json::JsonReaderHelper::GetUtf8FromText(json, utf8);
522 utf8 = utf8.Slice(0, actualByteCount);
523 return ReadFromSpan<TValue>(utf8, jsonTypeInfo, actualByteCount);
524 }
525 catch (...)
526 {
527 throw;
528 }
529 }
530 }
531
532 static System::SharedPtr<Object> ReadFromSpanAsObject(ReadOnlySpan<char16_t> json, System::SharedPtr<Serialization::Metadata::JsonTypeInfoBase> jsonTypeInfo);
533 template<typename TValue>
534 static TValue ReadFromSpan(ReadOnlySpan<uint8_t> utf8Json, System::SharedPtr<Serialization::Metadata::JsonTypeInfo<TValue>> jsonTypeInfo, Nullable<int32_t> actualByteCount = nullptr)
535 {
536 ASPOSE_UNUSED(actualByteCount);
537
538 JsonReaderState readerState(jsonTypeInfo->get_Options()->GetReaderOptions());
539 Utf8JsonReader reader(utf8Json, true, readerState);
540
541 ReadStack state = System::Default<System::Text::Json::ReadStack>();
542 state.Initialize(jsonTypeInfo);
543
544 TValue value = jsonTypeInfo->Deserialize(System::Ref(reader), System::Ref(state));
545
546 // The reader should have thrown if we have remaining bytes, unless AllowMultipleValues is true.
547
548 return value;
549 }
550
551 static System::SharedPtr<Object> ReadFromSpanAsObject(ReadOnlySpan<uint8_t> utf8Json, System::SharedPtr<Serialization::Metadata::JsonTypeInfoBase> jsonTypeInfo, Nullable<int32_t> actualByteCount = nullptr);
552
553 template<typename TValue>
554 static String WriteString(const TValue& value, System::SharedPtr<Serialization::Metadata::JsonTypeInfo<TValue>> jsonTypeInfo)
555 {
556
559
560 {
561 auto __finally_guard_0 = ::System::MakeScopeGuard([&output, &writer]()
562 {
564 });
565
566 try
567 {
568 jsonTypeInfo->Serialize(writer, value);
569 return System::Text::Json::JsonReaderHelper::TranscodeHelper(output->get_WrittenSpan());
570 }
571 catch (...)
572 {
573 throw;
574 }
575 }
576 }
577
578 static String WriteStringAsObject(System::SharedPtr<Object> value, System::SharedPtr<Serialization::Metadata::JsonTypeInfoBase> jsonTypeInfo);
579 template<typename TValue>
580 static System::SharedPtr<JsonDocument> WriteDocument(const TValue& value, System::SharedPtr<Serialization::Metadata::JsonTypeInfo<TValue>> jsonTypeInfo)
581 {
582
583 System::SharedPtr<JsonSerializerOptions> options = jsonTypeInfo->get_Options();
584
585 // For performance, share the same buffer across serialization and deserialization.
586 // The PooledByteBufferWriter is cleared and returned when JsonDocument.Dispose() is called.
587 System::SharedPtr<PooledByteBufferWriter> output = System::MakeObject<PooledByteBufferWriter>(options->get_DefaultBufferSize());
589
590 {
591 auto __finally_guard_0 = ::System::MakeScopeGuard([&writer]()
592 {
594 });
595
596 try
597 {
598 jsonTypeInfo->Serialize(writer, value);
599 return System::Text::Json::JsonDocument::ParseRented(output, options->GetDocumentOptions());
600 }
601 catch (...)
602 {
603 throw;
604 }
605 }
606 }
607
609 template<typename TValue>
610 static System::SharedPtr<Nodes::JsonNode> WriteNode(const TValue& value, System::SharedPtr<Serialization::Metadata::JsonTypeInfo<TValue>> jsonTypeInfo)
611 {
612
613 System::SharedPtr<JsonSerializerOptions> options = jsonTypeInfo->get_Options();
614
617
618 {
619 auto __finally_guard_0 = ::System::MakeScopeGuard([&output, &writer]()
620 {
622 });
623
624 try
625 {
626 jsonTypeInfo->Serialize(writer, value);
627 return System::Text::Json::Nodes::JsonNode::Parse(output->get_WrittenSpan(), options->GetNodeOptions(), options->GetDocumentOptions());
628 }
629 catch (...)
630 {
631 throw;
632 }
633 }
634 }
635
637 template<typename TValue>
638 static JsonElement WriteElement(const TValue& value, System::SharedPtr<Serialization::Metadata::JsonTypeInfo<TValue>> jsonTypeInfo)
639 {
640
641 System::SharedPtr<JsonSerializerOptions> options = jsonTypeInfo->get_Options();
642
645
646 {
647 auto __finally_guard_0 = ::System::MakeScopeGuard([&output, &writer]()
648 {
650 });
651
652 try
653 {
654 jsonTypeInfo->Serialize(writer, value);
655 return System::Text::Json::JsonElement::Parse(output->get_WrittenSpan(), options->GetDocumentOptions());
656 }
657 catch (...)
658 {
659 throw;
660 }
661 }
662 }
663
664 static JsonElement WriteElementAsObject(System::SharedPtr<Object> value, System::SharedPtr<Serialization::Metadata::JsonTypeInfoBase> jsonTypeInfo);
665 template<typename TValue>
666 static System::SharedPtr<Array<uint8_t>> WriteBytes(const TValue& value, System::SharedPtr<Serialization::Metadata::JsonTypeInfo<TValue>> jsonTypeInfo)
667 {
668
671
672 {
673 auto __finally_guard_0 = ::System::MakeScopeGuard([&output, &writer]()
674 {
676 });
677
678 try
679 {
680 jsonTypeInfo->Serialize(writer, value);
681 return output->get_WrittenSpan().ToArray();
682 }
683 catch (...)
684 {
685 throw;
686 }
687 }
688 }
689
691
692 static struct __StaticConstructor__ { __StaticConstructor__(); } s_constructor__;
693
694public:
695 JsonSerializer() = delete;
696};
697
698} // namespace Json
699} // namespace Text
700} // namespace System
ReadOnlySpan< T > get_Span() const
Gets a read-only span that represents the current memory.
Definition: memory.h:243
Pointer class to wrap types being allocated on heap. Use it to manage memory for classes inheriting O...
Definition: smart_ptr.h:180
String class used across the library. Is a substitute for C# System.String when translating code....
Definition: string.h:126
static const int64_t ArrayPoolMaxSizeBeforeUsingNormalAlloc
Definition: json_constants.h:65
static const int32_t StackallocByteThreshold
Definition: json_constants.h:107
static const int32_t MaxExpansionFactorWhileTranscoding
Definition: json_constants.h:64
static System::SharedPtr< JsonDocument > ParseRented(System::SharedPtr< PooledByteBufferWriter > utf8Json, JsonDocumentOptions options=System::Default< System::Text::Json::JsonDocumentOptions >())
Definition: json_element.h:59
ReadOnlyMemory< uint8_t > GetRawValue()
static JsonElement Parse(ReadOnlySpan< uint8_t > utf8Json, JsonDocumentOptions options=System::Default< System::Text::Json::JsonDocumentOptions >())
Definition: json_encoded_text.h:29
static int32_t GetUtf8ByteCount(ReadOnlySpan< char16_t > text)
static String TranscodeHelper(ReadOnlySpan< uint8_t > utf8Unescaped)
static int32_t GetUtf8FromText(ReadOnlySpan< char16_t > text, Span< uint8_t > dest)
Definition: json_serializer_helpers.h:91
static T UnboxOnRead(System::SharedPtr< Object > value)
Definition: json_serializer_helpers.h:380
static void Serialize(System::SharedPtr< IO::Stream > utf8Json, System::SharedPtr< Object > value, const TypeInfo &inputType, System::SharedPtr< Serialization::JsonSerializerContext > context)
static System::SharedPtr< Object > Deserialize(JsonElement element, const TypeInfo &returnType, System::SharedPtr< Serialization::JsonSerializerContext > context)
static System::SharedPtr< Serialization::Metadata::JsonPropertyInfoBase > LookupProperty(System::SharedPtr< Object > obj, ReadOnlySpan< uint8_t > unescapedPropertyName, ReadStack &state, System::SharedPtr< JsonSerializerOptions > options, bool &useExtensionProperty, bool createExtensionProperty=true)
static TValue Deserialize(String json, System::SharedPtr< Serialization::Metadata::JsonTypeInfo< TValue > > jsonTypeInfo)
Definition: json_serializer_helpers.h:175
static String Serialize(TValue value, System::SharedPtr< Serialization::Metadata::JsonTypeInfo< TValue > > jsonTypeInfo)
Definition: json_serializer_helpers.h:286
static const float FlushThreshold
Definition: json_serializer_helpers.h:367
static T UnboxOnWrite(System::SharedPtr< Object > value)
Definition: json_serializer_helpers.h:386
static System::SharedPtr< Object > Deserialize(ReadOnlySpan< uint8_t > utf8Json, const TypeInfo &returnType, System::SharedPtr< Serialization::JsonSerializerContext > context)
static const String ValuesPropertyName
Definition: json_serializer_helpers.h:374
static System::SharedPtr< Nodes::JsonNode > SerializeToNode(System::SharedPtr< Object > value, System::SharedPtr< Serialization::Metadata::JsonTypeInfoBase > jsonTypeInfo)
static System::SharedPtr< Object > Deserialize(System::SharedPtr< JsonDocument > document, System::SharedPtr< Serialization::Metadata::JsonTypeInfoBase > jsonTypeInfo)
friend class ThrowHelper
Definition: json_serializer_helpers.h:101
static System::SharedPtr< Object > Deserialize(ReadOnlySpan< char16_t > json, System::SharedPtr< Serialization::Metadata::JsonTypeInfoBase > jsonTypeInfo)
static JsonElement SerializeToElement(System::SharedPtr< Object > value, System::SharedPtr< Serialization::Metadata::JsonTypeInfoBase > jsonTypeInfo)
static void Serialize(System::SharedPtr< IO::Stream > utf8Json, System::SharedPtr< Object > value, System::SharedPtr< Serialization::Metadata::JsonTypeInfoBase > jsonTypeInfo)
static TValue Deserialize(String json, System::SharedPtr< JsonSerializerOptions > options)
Definition: json_serializer_helpers.h:203
static ReadOnlySpan< uint8_t > GetPropertyName(ReadStack &state, Utf8JsonReader &reader, System::SharedPtr< JsonSerializerOptions > options, bool &isAlreadyReadMetadataProperty)
static TValue Deserialize(ReadOnlySpan< uint8_t > utf8Json, System::SharedPtr< Serialization::Metadata::JsonTypeInfo< TValue > > jsonTypeInfo)
Definition: json_serializer_helpers.h:236
static MetadataPropertyName WriteMetadataForCollection(System::SharedPtr< Serialization::JsonConverterBase > jsonConverter, WriteStack &state, System::SharedPtr< Utf8JsonWriter > writer)
static System::SharedPtr< Object > Deserialize(String json, System::SharedPtr< Serialization::Metadata::JsonTypeInfoBase > jsonTypeInfo)
static String Serialize(System::SharedPtr< Object > value, System::SharedPtr< Serialization::Metadata::JsonTypeInfoBase > jsonTypeInfo)
static System::SharedPtr< Nodes::JsonNode > SerializeToNode(TValue value, System::SharedPtr< Serialization::Metadata::JsonTypeInfo< TValue > > jsonTypeInfo)
Definition: json_serializer_helpers.h:325
static System::SharedPtr< Object > Deserialize(JsonElement element, System::SharedPtr< Serialization::Metadata::JsonTypeInfoBase > jsonTypeInfo)
static TValue Deserialize(ReadOnlySpan< char16_t > json, System::SharedPtr< Serialization::Metadata::JsonTypeInfo< TValue > > jsonTypeInfo)
Definition: json_serializer_helpers.h:191
static MetadataPropertyName GetMetadataPropertyName(ReadOnlySpan< uint8_t > propertyName, System::SharedPtr< Serialization::Metadata::PolymorphicTypeResolver > resolver)
static System::SharedPtr< Object > Deserialize(ReadOnlySpan< uint8_t > utf8Json, System::SharedPtr< Serialization::Metadata::JsonTypeInfoBase > jsonTypeInfo)
static void ValidateMetadataForObjectConverter(ReadStack &state)
static bool IsValidNumberHandlingValue(Serialization::JsonNumberHandling handling)
static System::SharedPtr< Object > Deserialize(System::SharedPtr< IO::Stream > utf8Json, System::SharedPtr< Serialization::Metadata::JsonTypeInfoBase > jsonTypeInfo)
static TValue Deserialize(JsonElement element, System::SharedPtr< Serialization::Metadata::JsonTypeInfo< TValue > > jsonTypeInfo)
Definition: json_serializer_helpers.h:132
static System::SharedPtr< Object > Deserialize(Utf8JsonReader &reader, const TypeInfo &returnType, System::SharedPtr< Serialization::JsonSerializerContext > context)
static System::SharedPtr< Object > Deserialize(Utf8JsonReader &reader, System::SharedPtr< Serialization::Metadata::JsonTypeInfoBase > jsonTypeInfo)
static void Serialize(System::SharedPtr< Utf8JsonWriter > writer, System::SharedPtr< Object > value, System::SharedPtr< Serialization::Metadata::JsonTypeInfoBase > jsonTypeInfo)
static JsonEncodedText s_metadataType
Definition: json_serializer_helpers.h:375
static TValue Deserialize(Utf8JsonReader &reader, System::SharedPtr< Serialization::Metadata::JsonTypeInfo< TValue > > jsonTypeInfo)
Definition: json_serializer_helpers.h:161
static void CreateExtensionDataProperty(System::SharedPtr< Object > obj, System::SharedPtr< Serialization::Metadata::JsonPropertyInfoBase > jsonPropertyInfo, System::SharedPtr< JsonSerializerOptions > options)
static System::SharedPtr< Array< uint8_t > > SerializeToUtf8Bytes(System::SharedPtr< Object > value, System::SharedPtr< Serialization::Metadata::JsonTypeInfoBase > jsonTypeInfo)
static const String TypePropertyName
Definition: json_serializer_helpers.h:373
static System::SharedPtr< Object > Deserialize(System::SharedPtr< IO::Stream > utf8Json, const TypeInfo &returnType, System::SharedPtr< Serialization::JsonSerializerContext > context)
static System::SharedPtr< Nodes::JsonNode > SerializeToNode(System::SharedPtr< Object > value, const TypeInfo &inputType, System::SharedPtr< Serialization::JsonSerializerContext > context)
static System::SharedPtr< Object > Deserialize(System::SharedPtr< Nodes::JsonNode > node, const TypeInfo &returnType, System::SharedPtr< Serialization::JsonSerializerContext > context)
static JsonEncodedText s_metadataValues
Definition: json_serializer_helpers.h:376
static const String SerializationUnreferencedCodeMessage
Definition: json_serializer_helpers.h:371
static MetadataPropertyName WriteMetadataForObject(System::SharedPtr< Serialization::JsonConverterBase > jsonConverter, WriteStack &state, System::SharedPtr< Utf8JsonWriter > writer)
static System::SharedPtr< JsonDocument > SerializeToDocument(TValue value, System::SharedPtr< Serialization::Metadata::JsonTypeInfo< TValue > > jsonTypeInfo)
Definition: json_serializer_helpers.h:311
static void Serialize(System::SharedPtr< IO::Stream > utf8Json, TValue value, System::SharedPtr< Serialization::Metadata::JsonTypeInfo< TValue > > jsonTypeInfo)
Definition: json_serializer_helpers.h:268
static void Serialize(System::SharedPtr< Utf8JsonWriter > writer, System::SharedPtr< Object > value, const TypeInfo &inputType, System::SharedPtr< Serialization::JsonSerializerContext > context)
static System::SharedPtr< Object > Deserialize(System::SharedPtr< Nodes::JsonNode > node, System::SharedPtr< Serialization::Metadata::JsonTypeInfoBase > jsonTypeInfo)
static System::SharedPtr< JsonDocument > SerializeToDocument(System::SharedPtr< Object > value, System::SharedPtr< Serialization::Metadata::JsonTypeInfoBase > jsonTypeInfo)
static JsonElement SerializeToElement(TValue value, System::SharedPtr< Serialization::Metadata::JsonTypeInfo< TValue > > jsonTypeInfo)
Definition: json_serializer_helpers.h:339
friend class JsonSerializerOptions
Definition: json_serializer_helpers.h:94
static System::SharedPtr< Array< uint8_t > > SerializeToUtf8Bytes(TValue value, System::SharedPtr< Serialization::Metadata::JsonTypeInfo< TValue > > jsonTypeInfo)
Definition: json_serializer_helpers.h:353
static bool IsMetadataPropertyName(ReadOnlySpan< uint8_t > propertyName, System::SharedPtr< Serialization::Metadata::PolymorphicTypeResolver > resolver)
static TValue Deserialize(System::SharedPtr< Nodes::JsonNode > node, System::SharedPtr< Serialization::Metadata::JsonTypeInfo< TValue > > jsonTypeInfo)
Definition: json_serializer_helpers.h:147
static TValue Deserialize(System::SharedPtr< IO::Stream > utf8Json, System::SharedPtr< Serialization::Metadata::JsonTypeInfo< TValue > > jsonTypeInfo)
Definition: json_serializer_helpers.h:218
static String Serialize(TValue value, System::SharedPtr< JsonSerializerOptions > options)
Definition: json_serializer_helpers.h:298
static String Serialize(System::SharedPtr< Object > value, const TypeInfo &inputType, System::SharedPtr< Serialization::JsonSerializerContext > context)
static void Serialize(System::SharedPtr< Utf8JsonWriter > writer, TValue value, System::SharedPtr< Serialization::Metadata::JsonTypeInfo< TValue > > jsonTypeInfo)
Definition: json_serializer_helpers.h:250
static System::SharedPtr< Array< uint8_t > > SerializeToUtf8Bytes(System::SharedPtr< Object > value, const TypeInfo &inputType, System::SharedPtr< Serialization::JsonSerializerContext > context)
static TValue Deserialize(System::SharedPtr< JsonDocument > document, System::SharedPtr< Serialization::Metadata::JsonTypeInfo< TValue > > jsonTypeInfo)
Definition: json_serializer_helpers.h:112
static void ValidateMetadataForArrayConverter(System::SharedPtr< Serialization::JsonConverterBase > converter, Utf8JsonReader &reader, ReadStack &state)
static System::SharedPtr< Object > Deserialize(String json, const TypeInfo &returnType, System::SharedPtr< Serialization::JsonSerializerContext > context)
static System::SharedPtr< Object > Deserialize(System::SharedPtr< JsonDocument > document, const TypeInfo &returnType, System::SharedPtr< Serialization::JsonSerializerContext > context)
static System::SharedPtr< JsonDocument > SerializeToDocument(System::SharedPtr< Object > value, const TypeInfo &inputType, System::SharedPtr< Serialization::JsonSerializerContext > context)
static const String SerializationRequiresDynamicCodeMessage
Definition: json_serializer_helpers.h:372
static bool TryReadMetadata(System::SharedPtr< Serialization::JsonConverterBase > converter, System::SharedPtr< Serialization::Metadata::JsonTypeInfoBase > jsonTypeInfo, Utf8JsonReader &reader, ReadStack &state)
static System::SharedPtr< Object > Deserialize(ReadOnlySpan< char16_t > json, const TypeInfo &returnType, System::SharedPtr< Serialization::JsonSerializerContext > context)
static JsonElement SerializeToElement(System::SharedPtr< Object > value, const TypeInfo &inputType, System::SharedPtr< Serialization::JsonSerializerContext > context)
static System::SharedPtr< JsonNode > Parse(Utf8JsonReader &reader, Nullable< JsonNodeOptions > nodeOptions=nullptr)
Definition: read_stack.h:35
Definition: object_with_parameterized_constructor_converter.h:64
Definition: json_collection_converter.h:43
Definition: json_converter_of_t.h:80
static void ThrowArgumentException_SerializerDoesNotSupportComments(String paramName)
Definition: utf8_json_reader.h:78
static System::SharedPtr< Utf8JsonWriter > RentWriterAndBuffer(System::SharedPtr< JsonSerializerOptions > options, System::SharedPtr< PooledByteBufferWriter > &bufferWriter)
static System::SharedPtr< Utf8JsonWriter > RentWriter(System::SharedPtr< JsonSerializerOptions > options, System::SharedPtr< Buffers::IBufferWriter< uint8_t > > bufferWriter)
static void ReturnWriter(System::SharedPtr< Utf8JsonWriter > writer)
static void ReturnWriterAndBuffer(System::SharedPtr< Utf8JsonWriter > writer, System::SharedPtr< PooledByteBufferWriter > bufferWriter)
Definition: write_stack.h:34
Represents a particular type and provides information about it.
Definition: type_info.h:109
@ Text
Defines color adjustment information for text.
JsonNumberHandling
Definition: json_number_handling.h:16
MetadataPropertyName
Definition: metadata_property_name.h:13
Definition: db_command.h:9
decltype(Ref(std::declval< T & >())) Ref(const std::reference_wrapper< T > &wrapper)
Wrapper to make sure Ref(std::ref(DynamicWeakPtr)) works.
Definition: dynamic_weak_ptr.h:207