@@ -423,6 +423,8 @@ module SystemTextJson =
423
423
| JObject x -> Success ( dictAsJsonObject x)
424
424
| a -> Decode.Fail.objExpected a
425
425
426
+ static member jsonOfJsonObject o = JObject o
427
+
426
428
#endif
427
429
428
430
#if NEWTONSOFT
@@ -442,8 +444,9 @@ module SystemTextJson =
442
444
match o.Type with
443
445
| JTokenType.Object -> Success ( o :?> JObject)
444
446
| _ -> Decode.Fail.objExpected o
445
-
446
447
448
+ static member jsonOfJsonObject o = o :> JToken
449
+
447
450
#endif
448
451
449
452
#if SYSTEMJSON
@@ -463,6 +466,8 @@ module SystemTextJson =
463
466
| :? JsonObject as x -> Success x
464
467
| _ -> Decode.Fail.objExpected o
465
468
469
+ static member jsonOfJsonObject ( o : JsonObject ) = o :> JsonValue
470
+
466
471
#endif
467
472
468
473
#if SYSTEMTEXTJSON
@@ -496,6 +501,8 @@ module SystemTextJson =
496
501
| JObject x -> Success ( dictAsJsonObject x)
497
502
| a -> Decode.Fail.objExpected a
498
503
504
+ static member jsonOfJsonObject ( o : JsonObject ) = JObject o
505
+
499
506
#endif
500
507
501
508
open Helpers
@@ -905,6 +912,7 @@ module SystemTextJson =
905
912
static member inline OfJson ( _ : 'R , _ : Default2 ) = fun js -> ( ^R : ( static member OfJson : JsonValue -> ^R ParseResult) js) : ^ R ParseResult
906
913
907
914
static member OfJson ( _ : JsonObject , _ : Default1 ) = JsonHelpers.jsonObjectOfJson
915
+ static member OfJson ( _ : JsonValue , _ : Default1 ) = Success
908
916
909
917
910
918
/// Maps Json to a type
@@ -1043,6 +1051,9 @@ module SystemTextJson =
1043
1051
static member inline ToJson ( t : 'T , _ : Default3 ) = ( ^T : ( static member ToJSON : ^T -> JsonValue) t)
1044
1052
static member inline ToJson ( t : 'T , _ : Default2 ) = ( ^T : ( static member ToJson : ^T -> JsonValue) t)
1045
1053
1054
+ static member ToJson ( t : JsonObject , _ : Default1 ) = JsonHelpers.jsonOfJsonObject t
1055
+ static member ToJson ( t : JsonValue , _ : Default1 ) = t
1056
+
1046
1057
/// Maps a value to Json
1047
1058
let inline toJson ( x : 't ) : JsonValue = ToJson.Invoke x
1048
1059
0 commit comments