22using System . Collections . Generic ;
33using System . Reflection ;
44using System . Text . Json ;
5- using System . Text . Json . Serialization ;
65using JetBrains . Annotations ;
76using JsonApiDotNetCore . Configuration ;
87using JsonApiDotNetCore . Resources ;
@@ -15,7 +14,7 @@ namespace JsonApiDotNetCore.Serialization.JsonConverters
1514 /// Converts <see cref="ResourceObject" /> to/from JSON.
1615 /// </summary>
1716 [ UsedImplicitly ( ImplicitUseKindFlags . InstantiatedNoFixedConstructorSignature ) ]
18- public sealed class ResourceObjectConverter : JsonConverter < ResourceObject >
17+ public sealed class ResourceObjectConverter : JsonObjectConverter < ResourceObject >
1918 {
2019 private static readonly JsonEncodedText TypeText = JsonEncodedText . Encode ( "type" ) ;
2120 private static readonly JsonEncodedText IdText = JsonEncodedText . Encode ( "id" ) ;
@@ -72,7 +71,7 @@ public override ResourceObject Read(ref Utf8JsonReader reader, Type typeToConver
7271 {
7372 // Newtonsoft.Json used to auto-convert number to strings, while System.Text.Json does not. This is so likely
7473 // to hit users during upgrade that we special-case for this and produce a helpful error message.
75- var jsonElement = JsonConverterSupport . ReadSubTree < JsonElement > ( ref reader , options ) ;
74+ var jsonElement = ReadSubTree < JsonElement > ( ref reader , options ) ;
7675 throw new JsonException ( $ "Failed to convert ID '{ jsonElement } ' of type '{ jsonElement . ValueKind } ' to type 'String'.") ;
7776 }
7877
@@ -99,17 +98,17 @@ public override ResourceObject Read(ref Utf8JsonReader reader, Type typeToConver
9998 }
10099 case "relationships" :
101100 {
102- resourceObject . Relationships = JsonConverterSupport . ReadSubTree < IDictionary < string , RelationshipObject > > ( ref reader , options ) ;
101+ resourceObject . Relationships = ReadSubTree < IDictionary < string , RelationshipObject > > ( ref reader , options ) ;
103102 break ;
104103 }
105104 case "links" :
106105 {
107- resourceObject . Links = JsonConverterSupport . ReadSubTree < ResourceLinks > ( ref reader , options ) ;
106+ resourceObject . Links = ReadSubTree < ResourceLinks > ( ref reader , options ) ;
108107 break ;
109108 }
110109 case "meta" :
111110 {
112- resourceObject . Meta = JsonConverterSupport . ReadSubTree < IDictionary < string , object > > ( ref reader , options ) ;
111+ resourceObject . Meta = ReadSubTree < IDictionary < string , object > > ( ref reader , options ) ;
113112 break ;
114113 }
115114 default :
@@ -124,7 +123,7 @@ public override ResourceObject Read(ref Utf8JsonReader reader, Type typeToConver
124123 }
125124 }
126125
127- throw JsonConverterSupport . GetEndOfStreamError ( ) ;
126+ throw GetEndOfStreamError ( ) ;
128127 }
129128
130129 private static string TryPeekType ( ref Utf8JsonReader reader )
@@ -196,7 +195,7 @@ private static IDictionary<string, object> ReadAttributes(ref Utf8JsonReader rea
196195 // Inside a JsonConverter there is no way to know where in the JSON object tree we are. And the serializer
197196 // is unable to provide the correct position either. So we avoid an exception and postpone producing an error
198197 // response to the post-processing phase, by setting a sentinel value.
199- var jsonElement = JsonConverterSupport . ReadSubTree < JsonElement > ( ref reader , options ) ;
198+ var jsonElement = ReadSubTree < JsonElement > ( ref reader , options ) ;
200199
201200 attributeValue = new JsonInvalidAttributeInfo ( attributeName , property . PropertyType , jsonElement . ToString ( ) ,
202201 jsonElement . ValueKind ) ;
@@ -215,7 +214,7 @@ private static IDictionary<string, object> ReadAttributes(ref Utf8JsonReader rea
215214 }
216215 }
217216
218- throw JsonConverterSupport . GetEndOfStreamError ( ) ;
217+ throw GetEndOfStreamError ( ) ;
219218 }
220219
221220 /// <summary>
@@ -240,25 +239,25 @@ public override void Write(Utf8JsonWriter writer, ResourceObject value, JsonSeri
240239 if ( ! value . Attributes . IsNullOrEmpty ( ) )
241240 {
242241 writer . WritePropertyName ( AttributesText ) ;
243- JsonConverterSupport . WriteSubTree ( writer , value . Attributes , options ) ;
242+ WriteSubTree ( writer , value . Attributes , options ) ;
244243 }
245244
246245 if ( ! value . Relationships . IsNullOrEmpty ( ) )
247246 {
248247 writer . WritePropertyName ( RelationshipsText ) ;
249- JsonConverterSupport . WriteSubTree ( writer , value . Relationships , options ) ;
248+ WriteSubTree ( writer , value . Relationships , options ) ;
250249 }
251250
252251 if ( value . Links != null && value . Links . HasValue ( ) )
253252 {
254253 writer . WritePropertyName ( LinksText ) ;
255- JsonConverterSupport . WriteSubTree ( writer , value . Links , options ) ;
254+ WriteSubTree ( writer , value . Links , options ) ;
256255 }
257256
258257 if ( ! value . Meta . IsNullOrEmpty ( ) )
259258 {
260259 writer . WritePropertyName ( MetaText ) ;
261- JsonConverterSupport . WriteSubTree ( writer , value . Meta , options ) ;
260+ WriteSubTree ( writer , value . Meta , options ) ;
262261 }
263262
264263 writer . WriteEndObject ( ) ;
0 commit comments