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 1
1
// Copyright (c) Microsoft Corporation. All rights reserved.
2
2
// Licensed under the MIT license.
3
3
4
- using System . Text . Json ;
5
4
using System . Text . Json . Nodes ;
6
- using System . Text . Json . Serialization ;
7
- using Microsoft . OpenApi . Any ;
8
5
9
6
namespace Microsoft . OpenApi . Helpers
10
7
{
11
8
internal static class JsonNodeCloneHelper
12
9
{
13
- private static readonly JsonSerializerOptions options = new ( )
14
- {
15
- ReferenceHandler = ReferenceHandler . IgnoreCycles
16
- } ;
17
-
18
10
internal static JsonNode Clone ( JsonNode value )
19
11
{
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 ( ) ;
38
13
}
39
14
}
40
15
}
You can’t perform that action at this time.
0 commit comments