File tree Expand file tree Collapse file tree 1 file changed +1
-26
lines changed
src/Microsoft.OpenApi/Helpers Expand file tree Collapse file tree 1 file changed +1
-26
lines changed Original file line number Diff line number Diff line change 11// Copyright (c) Microsoft Corporation. All rights reserved.
22// Licensed under the MIT license.
33
4- using System . Text . Json ;
54using System . Text . Json . Nodes ;
6- using System . Text . Json . Serialization ;
7- using Microsoft . OpenApi . Any ;
85
96namespace Microsoft . OpenApi . Helpers
107{
118 internal static class JsonNodeCloneHelper
129 {
13- private static readonly JsonSerializerOptions options = new ( )
14- {
15- ReferenceHandler = ReferenceHandler . IgnoreCycles
16- } ;
17-
1810 internal static JsonNode Clone ( JsonNode value )
1911 {
20- var jsonString = Serialize ( value ) ;
21- if ( string . IsNullOrEmpty ( jsonString ) )
22- {
23- return null ;
24- }
25-
26- var result = JsonSerializer . Deserialize < JsonNode > ( jsonString , options ) ;
27- return result ;
28- }
29-
30- private static string Serialize ( object obj )
31- {
32- if ( obj == null )
33- {
34- return null ;
35- }
36- var result = JsonSerializer . Serialize ( obj , options ) ;
37- return result ;
12+ return value . DeepClone ( ) ;
3813 }
3914 }
4015}
You can’t perform that action at this time.
0 commit comments