44using System . Net ;
55using System . Net . Http ;
66using System . Net . Http . Headers ;
7- using Newtonsoft . Json ;
8- using Newtonsoft . Json . Linq ;
7+ using System . Text . Json ;
8+ using System . Text . Json . Nodes ;
99
1010namespace contentstack . CMA . Http
1111{
@@ -20,7 +20,7 @@ public class ContentstackResponse : IResponse, IDisposable
2020 Dictionary < string , string > _headers ;
2121 HashSet < string > _headerNamesSet ;
2222 private readonly HttpResponseMessage _response ;
23- private readonly JsonSerializer _serializer ;
23+ private readonly JsonSerializerOptions _options ;
2424
2525 #region Public
2626 /// <summary>
@@ -126,10 +126,10 @@ private void CopyHeaderValues(HttpResponseMessage response)
126126 }
127127 #endregion
128128
129- internal ContentstackResponse ( HttpResponseMessage response , JsonSerializer serializer )
129+ internal ContentstackResponse ( HttpResponseMessage response , JsonSerializerOptions options )
130130 {
131131 _response = response ;
132- _serializer = serializer ;
132+ _options = options ;
133133
134134 this . StatusCode = response . StatusCode ;
135135 this . IsSuccessStatusCode = response . IsSuccessStatusCode ;
@@ -146,11 +146,11 @@ internal ContentstackResponse(HttpResponseMessage response, JsonSerializer seria
146146 /// <summary>
147147 /// Json Object format response.
148148 /// </summary>
149- /// <returns>The JObject .</returns>
150- public JObject OpenJObjectResponse ( )
149+ /// <returns>The JsonObject .</returns>
150+ public JsonObject OpenJsonObjectResponse ( )
151151 {
152152 ThrowIfDisposed ( ) ;
153- return JObject . Parse ( OpenResponse ( ) ) ;
153+ return JsonNode . Parse ( OpenResponse ( ) ) ! . AsObject ( ) ;
154154 }
155155
156156 /// <summary>
@@ -171,8 +171,8 @@ public string OpenResponse()
171171 public TResponse OpenTResponse < TResponse > ( )
172172 {
173173 ThrowIfDisposed ( ) ;
174- JObject jObject = OpenJObjectResponse ( ) ;
175- return jObject . ToObject < TResponse > ( _serializer ) ;
174+ JsonObject jObject = OpenJsonObjectResponse ( ) ;
175+ return JsonSerializer . Deserialize < TResponse > ( jObject . ToJsonString ( ) , _options ) ! ;
176176 }
177177
178178
0 commit comments