diff --git a/docs/features/dependencyinjection.rst b/docs/features/dependencyinjection.rst index dca35b137..80e85600e 100644 --- a/docs/features/dependencyinjection.rst +++ b/docs/features/dependencyinjection.rst @@ -127,6 +127,14 @@ Current `implementation + { + op.JsonSerializerOptions.ReferenceHandler = ReferenceHandler.IgnoreCycles; + op.JsonSerializerOptions.NumberHandling = JsonNumberHandling.AllowReadingFromString; + op.JsonSerializerOptions.WriteIndented = false; + op.JsonSerializerOptions.PropertyNameCaseInsensitive = true; + op.JsonSerializerOptions.Encoder = JavaScriptEncoder.Create(UnicodeRanges.All); + }); } The method cannot be overridden. It is not virtual, and there is no way to override the current behavior by inheritance. diff --git a/src/Ocelot.Cache.CacheManager/packages.lock.json b/src/Ocelot.Cache.CacheManager/packages.lock.json index 906909875..314072a66 100644 --- a/src/Ocelot.Cache.CacheManager/packages.lock.json +++ b/src/Ocelot.Cache.CacheManager/packages.lock.json @@ -88,15 +88,6 @@ "resolved": "6.3.0", "contentHash": "VrGoeUz+ZK2QiwHNj+vab9uOvTDucenRseJZjc4uB7ASduQ7RNWnpd8gy1e9z2BsY4VoigVaCRrcQCQKuQVSiw==" }, - "Microsoft.AspNetCore.JsonPatch": { - "type": "Transitive", - "resolved": "8.0.22", - "contentHash": "gquk+JFVSXMJSHP/wWBgF6gYrwk616T6uJPaXvdXxBTRe43KTzuW0M+eMVlJsDH/lHGvItdjv47Y6uJ7WQVoSg==", - "dependencies": { - "Microsoft.CSharp": "4.7.0", - "Newtonsoft.Json": "13.0.3" - } - }, "Microsoft.AspNetCore.MiddlewareAnalysis": { "type": "Transitive", "resolved": "8.0.22", @@ -105,21 +96,6 @@ "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.2" } }, - "Microsoft.AspNetCore.Mvc.NewtonsoftJson": { - "type": "Transitive", - "resolved": "8.0.22", - "contentHash": "jSMF5XkqtWvFyvyVJFKrgmGhMh1sDKzIHa+S4WVXa1AY/F0Wou+uFbjO1DPlHt/TWdsWhuhVI1nF0yqIgxRrKQ==", - "dependencies": { - "Microsoft.AspNetCore.JsonPatch": "8.0.22", - "Newtonsoft.Json": "13.0.3", - "Newtonsoft.Json.Bson": "1.0.2" - } - }, - "Microsoft.CSharp": { - "type": "Transitive", - "resolved": "4.7.0", - "contentHash": "pTj+D3uJWyN3My70i2Hqo+OXixq3Os2D1nJ2x92FFo6sk8fYS1m1WLNTs0Dc1uPaViH0YvEEwvzddQ7y4rhXmA==" - }, "Microsoft.Extensions.Configuration.Abstractions": { "type": "Transitive", "resolved": "9.0.11", @@ -169,19 +145,6 @@ "resolved": "6.0.0", "contentHash": "hqTM5628jSsQiv+HGpiq3WKBl2c8v1KZfby2J6Pr7pEPlK9waPdgEO6b8A/+/xn/yZ9ulv8HuqK71ONy2tg67A==" }, - "Newtonsoft.Json": { - "type": "Transitive", - "resolved": "13.0.3", - "contentHash": "HrC5BXdl00IP9zeV+0Z848QWPAoCr9P3bDEZguI+gkLcBKAOxix/tLEAAHC+UvDNPv4a2d18lOReHMOagPa+zQ==" - }, - "Newtonsoft.Json.Bson": { - "type": "Transitive", - "resolved": "1.0.2", - "contentHash": "QYFyxhaABwmq3p/21VrZNYvCg3DaEoN/wUuw5nmfAf0X3HLjgupwhkEWdgfb9nvGAUIv3osmZoD3kKl4jxEmYQ==", - "dependencies": { - "Newtonsoft.Json": "12.0.1" - } - }, "StyleCop.Analyzers.Unstable": { "type": "Transitive", "resolved": "1.2.0.556", @@ -209,6 +172,11 @@ "Microsoft.Win32.SystemEvents": "6.0.0" } }, + "System.IO.Pipelines": { + "type": "Transitive", + "resolved": "9.0.12", + "contentHash": "LyvCiOzotNkRgn4wtksKjp/KEljoNtQpuAdunh6PipeyRP/qIdzmeeIjFLUaknkk237eMuYYi2YbkG0pbFBpDg==" + }, "System.Security.AccessControl": { "type": "Transitive", "resolved": "6.0.0", @@ -228,6 +196,20 @@ "System.Windows.Extensions": "6.0.0" } }, + "System.Text.Encodings.Web": { + "type": "Transitive", + "resolved": "9.0.12", + "contentHash": "T69549unMgkU+kbmDOVWYplDiJP6+b1V4NxXh/ao6ITp9xfWCeNPd/H8OI/WLxM/jjYreAVOLJaNayxtFVd7vA==" + }, + "System.Text.Json": { + "type": "Transitive", + "resolved": "9.0.12", + "contentHash": "wHv2GrfYd4/uaoZQJj6NOR8M0AlnWJ2/MFAHQomSMqk+/rSIY6AlcitL6LXbTgXf8+ngGjAAmQm17kfbNplQ9w==", + "dependencies": { + "System.IO.Pipelines": "9.0.12", + "System.Text.Encodings.Web": "9.0.12" + } + }, "System.Windows.Extensions": { "type": "Transitive", "resolved": "6.0.0", @@ -242,8 +224,8 @@ "FluentValidation": "[12.1.1, )", "IPAddressRange": "[6.3.0, )", "Microsoft.AspNetCore.MiddlewareAnalysis": "[8.0.22, )", - "Microsoft.AspNetCore.Mvc.NewtonsoftJson": "[8.0.22, )", - "Microsoft.Extensions.DiagnosticAdapter": "[3.1.32, )" + "Microsoft.Extensions.DiagnosticAdapter": "[3.1.32, )", + "System.Text.Json": "[9.0.12, )" } } }, @@ -271,6 +253,11 @@ "resolved": "6.0.0", "contentHash": "rp1gMNEZpvx9vP0JW0oHLxlf8oSiQgtno77Y4PLUBjSiDYoD77Y8uXHr1Ea5XG4/pIKhqAdxZ8v8OTUtqo9PeQ==" }, + "System.Text.Encodings.Web": { + "type": "Transitive", + "resolved": "9.0.12", + "contentHash": "T69549unMgkU+kbmDOVWYplDiJP6+b1V4NxXh/ao6ITp9xfWCeNPd/H8OI/WLxM/jjYreAVOLJaNayxtFVd7vA==" + }, "System.Windows.Extensions": { "type": "Transitive", "resolved": "6.0.0", @@ -304,6 +291,11 @@ "resolved": "6.0.0", "contentHash": "rp1gMNEZpvx9vP0JW0oHLxlf8oSiQgtno77Y4PLUBjSiDYoD77Y8uXHr1Ea5XG4/pIKhqAdxZ8v8OTUtqo9PeQ==" }, + "System.Text.Encodings.Web": { + "type": "Transitive", + "resolved": "9.0.12", + "contentHash": "T69549unMgkU+kbmDOVWYplDiJP6+b1V4NxXh/ao6ITp9xfWCeNPd/H8OI/WLxM/jjYreAVOLJaNayxtFVd7vA==" + }, "System.Windows.Extensions": { "type": "Transitive", "resolved": "6.0.0", @@ -400,15 +392,6 @@ "resolved": "6.3.0", "contentHash": "VrGoeUz+ZK2QiwHNj+vab9uOvTDucenRseJZjc4uB7ASduQ7RNWnpd8gy1e9z2BsY4VoigVaCRrcQCQKuQVSiw==" }, - "Microsoft.AspNetCore.JsonPatch": { - "type": "Transitive", - "resolved": "9.0.11", - "contentHash": "Q+A8LiyaUBurFMSdAzKTpT8jEa9Sc8EsNK0sJEA6glRP4vVl7OGXLV07bfDhcVlFU2hUkn+6Ofmw7HQ0cJ1n1g==", - "dependencies": { - "Microsoft.CSharp": "4.7.0", - "Newtonsoft.Json": "13.0.3" - } - }, "Microsoft.AspNetCore.MiddlewareAnalysis": { "type": "Transitive", "resolved": "9.0.11", @@ -417,21 +400,6 @@ "Microsoft.Extensions.DependencyInjection.Abstractions": "9.0.11" } }, - "Microsoft.AspNetCore.Mvc.NewtonsoftJson": { - "type": "Transitive", - "resolved": "9.0.11", - "contentHash": "xbpMq5ptjbTivpGz76NQ80Z3Oy204ndTJGoUdQB+vF0DOoii/loz1gr/q2KdFdloAFXju0v4lTiWEhGcIKmtyQ==", - "dependencies": { - "Microsoft.AspNetCore.JsonPatch": "9.0.11", - "Newtonsoft.Json": "13.0.3", - "Newtonsoft.Json.Bson": "1.0.2" - } - }, - "Microsoft.CSharp": { - "type": "Transitive", - "resolved": "4.7.0", - "contentHash": "pTj+D3uJWyN3My70i2Hqo+OXixq3Os2D1nJ2x92FFo6sk8fYS1m1WLNTs0Dc1uPaViH0YvEEwvzddQ7y4rhXmA==" - }, "Microsoft.Extensions.Configuration.Abstractions": { "type": "Transitive", "resolved": "9.0.11", @@ -480,19 +448,6 @@ "resolved": "6.0.0", "contentHash": "hqTM5628jSsQiv+HGpiq3WKBl2c8v1KZfby2J6Pr7pEPlK9waPdgEO6b8A/+/xn/yZ9ulv8HuqK71ONy2tg67A==" }, - "Newtonsoft.Json": { - "type": "Transitive", - "resolved": "13.0.3", - "contentHash": "HrC5BXdl00IP9zeV+0Z848QWPAoCr9P3bDEZguI+gkLcBKAOxix/tLEAAHC+UvDNPv4a2d18lOReHMOagPa+zQ==" - }, - "Newtonsoft.Json.Bson": { - "type": "Transitive", - "resolved": "1.0.2", - "contentHash": "QYFyxhaABwmq3p/21VrZNYvCg3DaEoN/wUuw5nmfAf0X3HLjgupwhkEWdgfb9nvGAUIv3osmZoD3kKl4jxEmYQ==", - "dependencies": { - "Newtonsoft.Json": "12.0.1" - } - }, "StyleCop.Analyzers.Unstable": { "type": "Transitive", "resolved": "1.2.0.556", @@ -539,6 +494,11 @@ "System.Windows.Extensions": "6.0.0" } }, + "System.Text.Json": { + "type": "Transitive", + "resolved": "9.0.12", + "contentHash": "wHv2GrfYd4/uaoZQJj6NOR8M0AlnWJ2/MFAHQomSMqk+/rSIY6AlcitL6LXbTgXf8+ngGjAAmQm17kfbNplQ9w==" + }, "System.Windows.Extensions": { "type": "Transitive", "resolved": "6.0.0", @@ -553,8 +513,8 @@ "FluentValidation": "[12.1.1, )", "IPAddressRange": "[6.3.0, )", "Microsoft.AspNetCore.MiddlewareAnalysis": "[9.0.11, )", - "Microsoft.AspNetCore.Mvc.NewtonsoftJson": "[9.0.11, )", - "Microsoft.Extensions.DiagnosticAdapter": "[3.1.32, )" + "Microsoft.Extensions.DiagnosticAdapter": "[3.1.32, )", + "System.Text.Json": "[9.0.12, )" } } }, diff --git a/src/Ocelot.Provider.Consul/ConsulFileConfigurationRepository.cs b/src/Ocelot.Provider.Consul/ConsulFileConfigurationRepository.cs index bfab032e8..1c2514ba9 100644 --- a/src/Ocelot.Provider.Consul/ConsulFileConfigurationRepository.cs +++ b/src/Ocelot.Provider.Consul/ConsulFileConfigurationRepository.cs @@ -1,13 +1,14 @@ using Microsoft.Extensions.Options; -using Newtonsoft.Json; using Ocelot.Cache; using Ocelot.Configuration; using Ocelot.Configuration.File; using Ocelot.Configuration.Repository; +using Ocelot.Infrastructure; using Ocelot.Logging; using Ocelot.Provider.Consul.Interfaces; using Ocelot.Responses; using System.Text; +using System.Text.Json; namespace Ocelot.Provider.Consul; @@ -53,14 +54,14 @@ public async Task> Get() var bytes = queryResult.Response.Value; var json = Encoding.UTF8.GetString(bytes); - var consulConfig = JsonConvert.DeserializeObject(json); + var consulConfig = JsonSerializer.Deserialize(json, OcelotSerializerOptions.Web); return new OkResponse(consulConfig); } public async Task Set(FileConfiguration ocelotConfiguration) { - var json = JsonConvert.SerializeObject(ocelotConfiguration, Formatting.Indented); + var json = JsonSerializer.Serialize(ocelotConfiguration, OcelotSerializerOptions.WebWriteIndented); var bytes = Encoding.UTF8.GetBytes(json); var kvPair = new KVPair(_configurationKey) { diff --git a/src/Ocelot.Provider.Consul/packages.lock.json b/src/Ocelot.Provider.Consul/packages.lock.json index 10f476fb7..f487699de 100644 --- a/src/Ocelot.Provider.Consul/packages.lock.json +++ b/src/Ocelot.Provider.Consul/packages.lock.json @@ -31,15 +31,6 @@ "resolved": "6.3.0", "contentHash": "VrGoeUz+ZK2QiwHNj+vab9uOvTDucenRseJZjc4uB7ASduQ7RNWnpd8gy1e9z2BsY4VoigVaCRrcQCQKuQVSiw==" }, - "Microsoft.AspNetCore.JsonPatch": { - "type": "Transitive", - "resolved": "8.0.22", - "contentHash": "gquk+JFVSXMJSHP/wWBgF6gYrwk616T6uJPaXvdXxBTRe43KTzuW0M+eMVlJsDH/lHGvItdjv47Y6uJ7WQVoSg==", - "dependencies": { - "Microsoft.CSharp": "4.7.0", - "Newtonsoft.Json": "13.0.3" - } - }, "Microsoft.AspNetCore.MiddlewareAnalysis": { "type": "Transitive", "resolved": "8.0.22", @@ -48,16 +39,6 @@ "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.2" } }, - "Microsoft.AspNetCore.Mvc.NewtonsoftJson": { - "type": "Transitive", - "resolved": "8.0.22", - "contentHash": "jSMF5XkqtWvFyvyVJFKrgmGhMh1sDKzIHa+S4WVXa1AY/F0Wou+uFbjO1DPlHt/TWdsWhuhVI1nF0yqIgxRrKQ==", - "dependencies": { - "Microsoft.AspNetCore.JsonPatch": "8.0.22", - "Newtonsoft.Json": "13.0.3", - "Newtonsoft.Json.Bson": "1.0.2" - } - }, "Microsoft.CSharp": { "type": "Transitive", "resolved": "4.7.0", @@ -78,16 +59,8 @@ }, "Newtonsoft.Json": { "type": "Transitive", - "resolved": "13.0.3", - "contentHash": "HrC5BXdl00IP9zeV+0Z848QWPAoCr9P3bDEZguI+gkLcBKAOxix/tLEAAHC+UvDNPv4a2d18lOReHMOagPa+zQ==" - }, - "Newtonsoft.Json.Bson": { - "type": "Transitive", - "resolved": "1.0.2", - "contentHash": "QYFyxhaABwmq3p/21VrZNYvCg3DaEoN/wUuw5nmfAf0X3HLjgupwhkEWdgfb9nvGAUIv3osmZoD3kKl4jxEmYQ==", - "dependencies": { - "Newtonsoft.Json": "12.0.1" - } + "resolved": "13.0.1", + "contentHash": "ppPFpBcvxdsfUonNcvITKqLl3bqxWbDCZIzDWHzjpdAHRFfZe0Dw9HmA0+za13IdyrgJwpkDTDA9fHaxOrt20A==" }, "StyleCop.Analyzers.Unstable": { "type": "Transitive", @@ -99,19 +72,50 @@ "resolved": "4.7.1", "contentHash": "j81Lovt90PDAq8kLpaJfJKV/rWdWuEk6jfV+MBkee33vzYLEUsy4gXK8laa9V2nZlLM9VM9yA/OOQxxPEJKAMw==" }, + "System.IO.Pipelines": { + "type": "Transitive", + "resolved": "9.0.12", + "contentHash": "LyvCiOzotNkRgn4wtksKjp/KEljoNtQpuAdunh6PipeyRP/qIdzmeeIjFLUaknkk237eMuYYi2YbkG0pbFBpDg==" + }, + "System.Text.Encodings.Web": { + "type": "Transitive", + "resolved": "9.0.12", + "contentHash": "T69549unMgkU+kbmDOVWYplDiJP6+b1V4NxXh/ao6ITp9xfWCeNPd/H8OI/WLxM/jjYreAVOLJaNayxtFVd7vA==" + }, + "System.Text.Json": { + "type": "Transitive", + "resolved": "9.0.12", + "contentHash": "wHv2GrfYd4/uaoZQJj6NOR8M0AlnWJ2/MFAHQomSMqk+/rSIY6AlcitL6LXbTgXf8+ngGjAAmQm17kfbNplQ9w==", + "dependencies": { + "System.IO.Pipelines": "9.0.12", + "System.Text.Encodings.Web": "9.0.12" + } + }, "ocelot": { "type": "Project", "dependencies": { "FluentValidation": "[12.1.1, )", "IPAddressRange": "[6.3.0, )", "Microsoft.AspNetCore.MiddlewareAnalysis": "[8.0.22, )", - "Microsoft.AspNetCore.Mvc.NewtonsoftJson": "[8.0.22, )", - "Microsoft.Extensions.DiagnosticAdapter": "[3.1.32, )" + "Microsoft.Extensions.DiagnosticAdapter": "[3.1.32, )", + "System.Text.Json": "[9.0.12, )" } } }, - "net8.0/osx-x64": {}, - "net8.0/win-x64": {}, + "net8.0/osx-x64": { + "System.Text.Encodings.Web": { + "type": "Transitive", + "resolved": "9.0.12", + "contentHash": "T69549unMgkU+kbmDOVWYplDiJP6+b1V4NxXh/ao6ITp9xfWCeNPd/H8OI/WLxM/jjYreAVOLJaNayxtFVd7vA==" + } + }, + "net8.0/win-x64": { + "System.Text.Encodings.Web": { + "type": "Transitive", + "resolved": "9.0.12", + "contentHash": "T69549unMgkU+kbmDOVWYplDiJP6+b1V4NxXh/ao6ITp9xfWCeNPd/H8OI/WLxM/jjYreAVOLJaNayxtFVd7vA==" + } + }, "net9.0": { "Consul": { "type": "Direct", @@ -142,15 +146,6 @@ "resolved": "6.3.0", "contentHash": "VrGoeUz+ZK2QiwHNj+vab9uOvTDucenRseJZjc4uB7ASduQ7RNWnpd8gy1e9z2BsY4VoigVaCRrcQCQKuQVSiw==" }, - "Microsoft.AspNetCore.JsonPatch": { - "type": "Transitive", - "resolved": "9.0.11", - "contentHash": "Q+A8LiyaUBurFMSdAzKTpT8jEa9Sc8EsNK0sJEA6glRP4vVl7OGXLV07bfDhcVlFU2hUkn+6Ofmw7HQ0cJ1n1g==", - "dependencies": { - "Microsoft.CSharp": "4.7.0", - "Newtonsoft.Json": "13.0.3" - } - }, "Microsoft.AspNetCore.MiddlewareAnalysis": { "type": "Transitive", "resolved": "9.0.11", @@ -159,16 +154,6 @@ "Microsoft.Extensions.DependencyInjection.Abstractions": "9.0.11" } }, - "Microsoft.AspNetCore.Mvc.NewtonsoftJson": { - "type": "Transitive", - "resolved": "9.0.11", - "contentHash": "xbpMq5ptjbTivpGz76NQ80Z3Oy204ndTJGoUdQB+vF0DOoii/loz1gr/q2KdFdloAFXju0v4lTiWEhGcIKmtyQ==", - "dependencies": { - "Microsoft.AspNetCore.JsonPatch": "9.0.11", - "Newtonsoft.Json": "13.0.3", - "Newtonsoft.Json.Bson": "1.0.2" - } - }, "Microsoft.CSharp": { "type": "Transitive", "resolved": "4.7.0", @@ -189,16 +174,8 @@ }, "Newtonsoft.Json": { "type": "Transitive", - "resolved": "13.0.3", - "contentHash": "HrC5BXdl00IP9zeV+0Z848QWPAoCr9P3bDEZguI+gkLcBKAOxix/tLEAAHC+UvDNPv4a2d18lOReHMOagPa+zQ==" - }, - "Newtonsoft.Json.Bson": { - "type": "Transitive", - "resolved": "1.0.2", - "contentHash": "QYFyxhaABwmq3p/21VrZNYvCg3DaEoN/wUuw5nmfAf0X3HLjgupwhkEWdgfb9nvGAUIv3osmZoD3kKl4jxEmYQ==", - "dependencies": { - "Newtonsoft.Json": "12.0.1" - } + "resolved": "13.0.1", + "contentHash": "ppPFpBcvxdsfUonNcvITKqLl3bqxWbDCZIzDWHzjpdAHRFfZe0Dw9HmA0+za13IdyrgJwpkDTDA9fHaxOrt20A==" }, "StyleCop.Analyzers.Unstable": { "type": "Transitive", @@ -210,14 +187,19 @@ "resolved": "4.7.1", "contentHash": "j81Lovt90PDAq8kLpaJfJKV/rWdWuEk6jfV+MBkee33vzYLEUsy4gXK8laa9V2nZlLM9VM9yA/OOQxxPEJKAMw==" }, + "System.Text.Json": { + "type": "Transitive", + "resolved": "9.0.12", + "contentHash": "wHv2GrfYd4/uaoZQJj6NOR8M0AlnWJ2/MFAHQomSMqk+/rSIY6AlcitL6LXbTgXf8+ngGjAAmQm17kfbNplQ9w==" + }, "ocelot": { "type": "Project", "dependencies": { "FluentValidation": "[12.1.1, )", "IPAddressRange": "[6.3.0, )", "Microsoft.AspNetCore.MiddlewareAnalysis": "[9.0.11, )", - "Microsoft.AspNetCore.Mvc.NewtonsoftJson": "[9.0.11, )", - "Microsoft.Extensions.DiagnosticAdapter": "[3.1.32, )" + "Microsoft.Extensions.DiagnosticAdapter": "[3.1.32, )", + "System.Text.Json": "[9.0.12, )" } } }, diff --git a/src/Ocelot.Provider.Eureka/packages.lock.json b/src/Ocelot.Provider.Eureka/packages.lock.json index 127caca47..234985fba 100644 --- a/src/Ocelot.Provider.Eureka/packages.lock.json +++ b/src/Ocelot.Provider.Eureka/packages.lock.json @@ -42,15 +42,6 @@ "resolved": "6.3.0", "contentHash": "VrGoeUz+ZK2QiwHNj+vab9uOvTDucenRseJZjc4uB7ASduQ7RNWnpd8gy1e9z2BsY4VoigVaCRrcQCQKuQVSiw==" }, - "Microsoft.AspNetCore.JsonPatch": { - "type": "Transitive", - "resolved": "8.0.22", - "contentHash": "gquk+JFVSXMJSHP/wWBgF6gYrwk616T6uJPaXvdXxBTRe43KTzuW0M+eMVlJsDH/lHGvItdjv47Y6uJ7WQVoSg==", - "dependencies": { - "Microsoft.CSharp": "4.7.0", - "Newtonsoft.Json": "13.0.3" - } - }, "Microsoft.AspNetCore.MiddlewareAnalysis": { "type": "Transitive", "resolved": "8.0.22", @@ -59,21 +50,6 @@ "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.2" } }, - "Microsoft.AspNetCore.Mvc.NewtonsoftJson": { - "type": "Transitive", - "resolved": "8.0.22", - "contentHash": "jSMF5XkqtWvFyvyVJFKrgmGhMh1sDKzIHa+S4WVXa1AY/F0Wou+uFbjO1DPlHt/TWdsWhuhVI1nF0yqIgxRrKQ==", - "dependencies": { - "Microsoft.AspNetCore.JsonPatch": "8.0.22", - "Newtonsoft.Json": "13.0.3", - "Newtonsoft.Json.Bson": "1.0.2" - } - }, - "Microsoft.CSharp": { - "type": "Transitive", - "resolved": "4.7.0", - "contentHash": "pTj+D3uJWyN3My70i2Hqo+OXixq3Os2D1nJ2x92FFo6sk8fYS1m1WLNTs0Dc1uPaViH0YvEEwvzddQ7y4rhXmA==" - }, "Microsoft.Extensions.Caching.Abstractions": { "type": "Transitive", "resolved": "8.0.0", @@ -382,19 +358,6 @@ "resolved": "8.0.0", "contentHash": "bXJEZrW9ny8vjMF1JV253WeLhpEVzFo1lyaZu1vQ4ZxWUlVvknZ/+ftFgVheLubb4eZPSwwxBeqS1JkCOjxd8g==" }, - "Newtonsoft.Json": { - "type": "Transitive", - "resolved": "13.0.3", - "contentHash": "HrC5BXdl00IP9zeV+0Z848QWPAoCr9P3bDEZguI+gkLcBKAOxix/tLEAAHC+UvDNPv4a2d18lOReHMOagPa+zQ==" - }, - "Newtonsoft.Json.Bson": { - "type": "Transitive", - "resolved": "1.0.2", - "contentHash": "QYFyxhaABwmq3p/21VrZNYvCg3DaEoN/wUuw5nmfAf0X3HLjgupwhkEWdgfb9nvGAUIv3osmZoD3kKl4jxEmYQ==", - "dependencies": { - "Newtonsoft.Json": "12.0.1" - } - }, "Steeltoe.Common": { "type": "Transitive", "resolved": "3.3.0", @@ -498,6 +461,11 @@ "resolved": "8.0.0", "contentHash": "fdYxcRjQqTTacKId/2IECojlDSFvp7LP5N78+0z/xH7v/Tuw5ZAxu23Y6PTCRinqyu2ePx+Gn1098NC6jM6d+A==" }, + "System.IO.Pipelines": { + "type": "Transitive", + "resolved": "9.0.12", + "contentHash": "LyvCiOzotNkRgn4wtksKjp/KEljoNtQpuAdunh6PipeyRP/qIdzmeeIjFLUaknkk237eMuYYi2YbkG0pbFBpDg==" + }, "System.Net.Http.Json": { "type": "Transitive", "resolved": "3.2.1", @@ -511,10 +479,19 @@ "resolved": "4.6.0", "contentHash": "TezS9fEP9kzL5U6GYHZY6I/tqz6qiHKNgAzuT6JJXJXuP+wWvNLN03gPxBK2uLP0LrLg/QXEAF++lxBNBSYILA==" }, + "System.Text.Encodings.Web": { + "type": "Transitive", + "resolved": "9.0.12", + "contentHash": "T69549unMgkU+kbmDOVWYplDiJP6+b1V4NxXh/ao6ITp9xfWCeNPd/H8OI/WLxM/jjYreAVOLJaNayxtFVd7vA==" + }, "System.Text.Json": { "type": "Transitive", - "resolved": "8.0.5", - "contentHash": "0f1B50Ss7rqxXiaBJyzUu9bWFOO2/zSlifZ/UNMdiIpDYe4cY4LQQicP4nirK1OS31I43rn062UIJ1Q9bpmHpg==" + "resolved": "9.0.12", + "contentHash": "wHv2GrfYd4/uaoZQJj6NOR8M0AlnWJ2/MFAHQomSMqk+/rSIY6AlcitL6LXbTgXf8+ngGjAAmQm17kfbNplQ9w==", + "dependencies": { + "System.IO.Pipelines": "9.0.12", + "System.Text.Encodings.Web": "9.0.12" + } }, "ocelot": { "type": "Project", @@ -522,8 +499,8 @@ "FluentValidation": "[12.1.1, )", "IPAddressRange": "[6.3.0, )", "Microsoft.AspNetCore.MiddlewareAnalysis": "[8.0.22, )", - "Microsoft.AspNetCore.Mvc.NewtonsoftJson": "[8.0.22, )", - "Microsoft.Extensions.DiagnosticAdapter": "[3.1.32, )" + "Microsoft.Extensions.DiagnosticAdapter": "[3.1.32, )", + "System.Text.Json": "[9.0.12, )" } } }, @@ -532,6 +509,11 @@ "type": "Transitive", "resolved": "8.0.0", "contentHash": "fdYxcRjQqTTacKId/2IECojlDSFvp7LP5N78+0z/xH7v/Tuw5ZAxu23Y6PTCRinqyu2ePx+Gn1098NC6jM6d+A==" + }, + "System.Text.Encodings.Web": { + "type": "Transitive", + "resolved": "9.0.12", + "contentHash": "T69549unMgkU+kbmDOVWYplDiJP6+b1V4NxXh/ao6ITp9xfWCeNPd/H8OI/WLxM/jjYreAVOLJaNayxtFVd7vA==" } }, "net8.0/win-x64": { @@ -539,6 +521,11 @@ "type": "Transitive", "resolved": "8.0.0", "contentHash": "fdYxcRjQqTTacKId/2IECojlDSFvp7LP5N78+0z/xH7v/Tuw5ZAxu23Y6PTCRinqyu2ePx+Gn1098NC6jM6d+A==" + }, + "System.Text.Encodings.Web": { + "type": "Transitive", + "resolved": "9.0.12", + "contentHash": "T69549unMgkU+kbmDOVWYplDiJP6+b1V4NxXh/ao6ITp9xfWCeNPd/H8OI/WLxM/jjYreAVOLJaNayxtFVd7vA==" } }, "net9.0": { @@ -582,15 +569,6 @@ "resolved": "6.3.0", "contentHash": "VrGoeUz+ZK2QiwHNj+vab9uOvTDucenRseJZjc4uB7ASduQ7RNWnpd8gy1e9z2BsY4VoigVaCRrcQCQKuQVSiw==" }, - "Microsoft.AspNetCore.JsonPatch": { - "type": "Transitive", - "resolved": "9.0.11", - "contentHash": "Q+A8LiyaUBurFMSdAzKTpT8jEa9Sc8EsNK0sJEA6glRP4vVl7OGXLV07bfDhcVlFU2hUkn+6Ofmw7HQ0cJ1n1g==", - "dependencies": { - "Microsoft.CSharp": "4.7.0", - "Newtonsoft.Json": "13.0.3" - } - }, "Microsoft.AspNetCore.MiddlewareAnalysis": { "type": "Transitive", "resolved": "9.0.11", @@ -599,21 +577,6 @@ "Microsoft.Extensions.DependencyInjection.Abstractions": "9.0.11" } }, - "Microsoft.AspNetCore.Mvc.NewtonsoftJson": { - "type": "Transitive", - "resolved": "9.0.11", - "contentHash": "xbpMq5ptjbTivpGz76NQ80Z3Oy204ndTJGoUdQB+vF0DOoii/loz1gr/q2KdFdloAFXju0v4lTiWEhGcIKmtyQ==", - "dependencies": { - "Microsoft.AspNetCore.JsonPatch": "9.0.11", - "Newtonsoft.Json": "13.0.3", - "Newtonsoft.Json.Bson": "1.0.2" - } - }, - "Microsoft.CSharp": { - "type": "Transitive", - "resolved": "4.7.0", - "contentHash": "pTj+D3uJWyN3My70i2Hqo+OXixq3Os2D1nJ2x92FFo6sk8fYS1m1WLNTs0Dc1uPaViH0YvEEwvzddQ7y4rhXmA==" - }, "Microsoft.Extensions.Caching.Abstractions": { "type": "Transitive", "resolved": "8.0.0", @@ -922,19 +885,6 @@ "resolved": "8.0.0", "contentHash": "bXJEZrW9ny8vjMF1JV253WeLhpEVzFo1lyaZu1vQ4ZxWUlVvknZ/+ftFgVheLubb4eZPSwwxBeqS1JkCOjxd8g==" }, - "Newtonsoft.Json": { - "type": "Transitive", - "resolved": "13.0.3", - "contentHash": "HrC5BXdl00IP9zeV+0Z848QWPAoCr9P3bDEZguI+gkLcBKAOxix/tLEAAHC+UvDNPv4a2d18lOReHMOagPa+zQ==" - }, - "Newtonsoft.Json.Bson": { - "type": "Transitive", - "resolved": "1.0.2", - "contentHash": "QYFyxhaABwmq3p/21VrZNYvCg3DaEoN/wUuw5nmfAf0X3HLjgupwhkEWdgfb9nvGAUIv3osmZoD3kKl4jxEmYQ==", - "dependencies": { - "Newtonsoft.Json": "12.0.1" - } - }, "Steeltoe.Common": { "type": "Transitive", "resolved": "3.3.0", @@ -1053,8 +1003,8 @@ }, "System.Text.Json": { "type": "Transitive", - "resolved": "8.0.5", - "contentHash": "0f1B50Ss7rqxXiaBJyzUu9bWFOO2/zSlifZ/UNMdiIpDYe4cY4LQQicP4nirK1OS31I43rn062UIJ1Q9bpmHpg==" + "resolved": "9.0.12", + "contentHash": "wHv2GrfYd4/uaoZQJj6NOR8M0AlnWJ2/MFAHQomSMqk+/rSIY6AlcitL6LXbTgXf8+ngGjAAmQm17kfbNplQ9w==" }, "ocelot": { "type": "Project", @@ -1062,8 +1012,8 @@ "FluentValidation": "[12.1.1, )", "IPAddressRange": "[6.3.0, )", "Microsoft.AspNetCore.MiddlewareAnalysis": "[9.0.11, )", - "Microsoft.AspNetCore.Mvc.NewtonsoftJson": "[9.0.11, )", - "Microsoft.Extensions.DiagnosticAdapter": "[3.1.32, )" + "Microsoft.Extensions.DiagnosticAdapter": "[3.1.32, )", + "System.Text.Json": "[9.0.12, )" } } }, diff --git a/src/Ocelot.Provider.Kubernetes/packages.lock.json b/src/Ocelot.Provider.Kubernetes/packages.lock.json index 29decb839..f06a3877a 100644 --- a/src/Ocelot.Provider.Kubernetes/packages.lock.json +++ b/src/Ocelot.Provider.Kubernetes/packages.lock.json @@ -93,8 +93,8 @@ }, "Microsoft.AspNetCore.JsonPatch": { "type": "Transitive", - "resolved": "8.0.22", - "contentHash": "gquk+JFVSXMJSHP/wWBgF6gYrwk616T6uJPaXvdXxBTRe43KTzuW0M+eMVlJsDH/lHGvItdjv47Y6uJ7WQVoSg==", + "resolved": "8.0.0", + "contentHash": "klQdb/9+j0u8MDjoqHEgDCPz8GRhfsbRVvZIM3glFqjs8uY7S1hS9RvKZuz8o4dS9NsEpFp4Jccd8CQuIYHK0g==", "dependencies": { "Microsoft.CSharp": "4.7.0", "Newtonsoft.Json": "13.0.3" @@ -108,16 +108,6 @@ "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.2" } }, - "Microsoft.AspNetCore.Mvc.NewtonsoftJson": { - "type": "Transitive", - "resolved": "8.0.22", - "contentHash": "jSMF5XkqtWvFyvyVJFKrgmGhMh1sDKzIHa+S4WVXa1AY/F0Wou+uFbjO1DPlHt/TWdsWhuhVI1nF0yqIgxRrKQ==", - "dependencies": { - "Microsoft.AspNetCore.JsonPatch": "8.0.22", - "Newtonsoft.Json": "13.0.3", - "Newtonsoft.Json.Bson": "1.0.2" - } - }, "Microsoft.CSharp": { "type": "Transitive", "resolved": "4.7.0", @@ -286,14 +276,6 @@ "resolved": "13.0.3", "contentHash": "HrC5BXdl00IP9zeV+0Z848QWPAoCr9P3bDEZguI+gkLcBKAOxix/tLEAAHC+UvDNPv4a2d18lOReHMOagPa+zQ==" }, - "Newtonsoft.Json.Bson": { - "type": "Transitive", - "resolved": "1.0.2", - "contentHash": "QYFyxhaABwmq3p/21VrZNYvCg3DaEoN/wUuw5nmfAf0X3HLjgupwhkEWdgfb9nvGAUIv3osmZoD3kKl4jxEmYQ==", - "dependencies": { - "Newtonsoft.Json": "12.0.1" - } - }, "runtime.native.System": { "type": "Transitive", "resolved": "4.3.0", @@ -411,6 +393,11 @@ "System.Runtime": "4.3.0" } }, + "System.IO.Pipelines": { + "type": "Transitive", + "resolved": "9.0.12", + "contentHash": "LyvCiOzotNkRgn4wtksKjp/KEljoNtQpuAdunh6PipeyRP/qIdzmeeIjFLUaknkk237eMuYYi2YbkG0pbFBpDg==" + }, "System.Reactive": { "type": "Transitive", "resolved": "6.0.1", @@ -513,10 +500,19 @@ "System.Text.Encoding": "4.3.0" } }, + "System.Text.Encodings.Web": { + "type": "Transitive", + "resolved": "9.0.12", + "contentHash": "T69549unMgkU+kbmDOVWYplDiJP6+b1V4NxXh/ao6ITp9xfWCeNPd/H8OI/WLxM/jjYreAVOLJaNayxtFVd7vA==" + }, "System.Text.Json": { "type": "Transitive", - "resolved": "8.0.5", - "contentHash": "0f1B50Ss7rqxXiaBJyzUu9bWFOO2/zSlifZ/UNMdiIpDYe4cY4LQQicP4nirK1OS31I43rn062UIJ1Q9bpmHpg==" + "resolved": "9.0.12", + "contentHash": "wHv2GrfYd4/uaoZQJj6NOR8M0AlnWJ2/MFAHQomSMqk+/rSIY6AlcitL6LXbTgXf8+ngGjAAmQm17kfbNplQ9w==", + "dependencies": { + "System.IO.Pipelines": "9.0.12", + "System.Text.Encodings.Web": "9.0.12" + } }, "System.Threading": { "type": "Transitive", @@ -565,8 +561,8 @@ "FluentValidation": "[12.1.1, )", "IPAddressRange": "[6.3.0, )", "Microsoft.AspNetCore.MiddlewareAnalysis": "[8.0.22, )", - "Microsoft.AspNetCore.Mvc.NewtonsoftJson": "[8.0.22, )", - "Microsoft.Extensions.DiagnosticAdapter": "[3.1.32, )" + "Microsoft.Extensions.DiagnosticAdapter": "[3.1.32, )", + "System.Text.Json": "[9.0.12, )" } } }, @@ -1022,6 +1018,11 @@ "runtime.any.System.Text.Encoding.Extensions": "4.3.0" } }, + "System.Text.Encodings.Web": { + "type": "Transitive", + "resolved": "9.0.12", + "contentHash": "T69549unMgkU+kbmDOVWYplDiJP6+b1V4NxXh/ao6ITp9xfWCeNPd/H8OI/WLxM/jjYreAVOLJaNayxtFVd7vA==" + }, "System.Threading.Tasks": { "type": "Transitive", "resolved": "4.3.0", @@ -1404,6 +1405,11 @@ "runtime.any.System.Text.Encoding.Extensions": "4.3.0" } }, + "System.Text.Encodings.Web": { + "type": "Transitive", + "resolved": "9.0.12", + "contentHash": "T69549unMgkU+kbmDOVWYplDiJP6+b1V4NxXh/ao6ITp9xfWCeNPd/H8OI/WLxM/jjYreAVOLJaNayxtFVd7vA==" + }, "System.Threading.Overlapped": { "type": "Transitive", "resolved": "4.3.0", @@ -1519,8 +1525,8 @@ }, "Microsoft.AspNetCore.JsonPatch": { "type": "Transitive", - "resolved": "9.0.11", - "contentHash": "Q+A8LiyaUBurFMSdAzKTpT8jEa9Sc8EsNK0sJEA6glRP4vVl7OGXLV07bfDhcVlFU2hUkn+6Ofmw7HQ0cJ1n1g==", + "resolved": "9.0.3", + "contentHash": "G4l8/XY06y6TYhQPAaDhlbEnc3aP8obYmQAv0WYQOKhXD6t8J0YKyS1TW0v3RteVDN6XsUten3BfqlvDF7Gxhg==", "dependencies": { "Microsoft.CSharp": "4.7.0", "Newtonsoft.Json": "13.0.3" @@ -1534,16 +1540,6 @@ "Microsoft.Extensions.DependencyInjection.Abstractions": "9.0.11" } }, - "Microsoft.AspNetCore.Mvc.NewtonsoftJson": { - "type": "Transitive", - "resolved": "9.0.11", - "contentHash": "xbpMq5ptjbTivpGz76NQ80Z3Oy204ndTJGoUdQB+vF0DOoii/loz1gr/q2KdFdloAFXju0v4lTiWEhGcIKmtyQ==", - "dependencies": { - "Microsoft.AspNetCore.JsonPatch": "9.0.11", - "Newtonsoft.Json": "13.0.3", - "Newtonsoft.Json.Bson": "1.0.2" - } - }, "Microsoft.CSharp": { "type": "Transitive", "resolved": "4.7.0", @@ -1711,14 +1707,6 @@ "resolved": "13.0.3", "contentHash": "HrC5BXdl00IP9zeV+0Z848QWPAoCr9P3bDEZguI+gkLcBKAOxix/tLEAAHC+UvDNPv4a2d18lOReHMOagPa+zQ==" }, - "Newtonsoft.Json.Bson": { - "type": "Transitive", - "resolved": "1.0.2", - "contentHash": "QYFyxhaABwmq3p/21VrZNYvCg3DaEoN/wUuw5nmfAf0X3HLjgupwhkEWdgfb9nvGAUIv3osmZoD3kKl4jxEmYQ==", - "dependencies": { - "Newtonsoft.Json": "12.0.1" - } - }, "runtime.native.System": { "type": "Transitive", "resolved": "4.3.0", @@ -1940,8 +1928,8 @@ }, "System.Text.Json": { "type": "Transitive", - "resolved": "9.0.2", - "contentHash": "4TY2Yokh5Xp8XHFhsY9y84yokS7B0rhkaZCXuRiKppIiKwPVH4lVSFD9EEFzRpXdBM5ZeZXD43tc2vB6njEwwQ==" + "resolved": "9.0.12", + "contentHash": "wHv2GrfYd4/uaoZQJj6NOR8M0AlnWJ2/MFAHQomSMqk+/rSIY6AlcitL6LXbTgXf8+ngGjAAmQm17kfbNplQ9w==" }, "System.Threading": { "type": "Transitive", @@ -1990,8 +1978,8 @@ "FluentValidation": "[12.1.1, )", "IPAddressRange": "[6.3.0, )", "Microsoft.AspNetCore.MiddlewareAnalysis": "[9.0.11, )", - "Microsoft.AspNetCore.Mvc.NewtonsoftJson": "[9.0.11, )", - "Microsoft.Extensions.DiagnosticAdapter": "[3.1.32, )" + "Microsoft.Extensions.DiagnosticAdapter": "[3.1.32, )", + "System.Text.Json": "[9.0.12, )" } } }, diff --git a/src/Ocelot.Provider.Polly/packages.lock.json b/src/Ocelot.Provider.Polly/packages.lock.json index 5efe6c199..34737f53f 100644 --- a/src/Ocelot.Provider.Polly/packages.lock.json +++ b/src/Ocelot.Provider.Polly/packages.lock.json @@ -30,15 +30,6 @@ "resolved": "6.3.0", "contentHash": "VrGoeUz+ZK2QiwHNj+vab9uOvTDucenRseJZjc4uB7ASduQ7RNWnpd8gy1e9z2BsY4VoigVaCRrcQCQKuQVSiw==" }, - "Microsoft.AspNetCore.JsonPatch": { - "type": "Transitive", - "resolved": "8.0.22", - "contentHash": "gquk+JFVSXMJSHP/wWBgF6gYrwk616T6uJPaXvdXxBTRe43KTzuW0M+eMVlJsDH/lHGvItdjv47Y6uJ7WQVoSg==", - "dependencies": { - "Microsoft.CSharp": "4.7.0", - "Newtonsoft.Json": "13.0.3" - } - }, "Microsoft.AspNetCore.MiddlewareAnalysis": { "type": "Transitive", "resolved": "8.0.22", @@ -47,21 +38,6 @@ "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.2" } }, - "Microsoft.AspNetCore.Mvc.NewtonsoftJson": { - "type": "Transitive", - "resolved": "8.0.22", - "contentHash": "jSMF5XkqtWvFyvyVJFKrgmGhMh1sDKzIHa+S4WVXa1AY/F0Wou+uFbjO1DPlHt/TWdsWhuhVI1nF0yqIgxRrKQ==", - "dependencies": { - "Microsoft.AspNetCore.JsonPatch": "8.0.22", - "Newtonsoft.Json": "13.0.3", - "Newtonsoft.Json.Bson": "1.0.2" - } - }, - "Microsoft.CSharp": { - "type": "Transitive", - "resolved": "4.7.0", - "contentHash": "pTj+D3uJWyN3My70i2Hqo+OXixq3Os2D1nJ2x92FFo6sk8fYS1m1WLNTs0Dc1uPaViH0YvEEwvzddQ7y4rhXmA==" - }, "Microsoft.Extensions.DependencyInjection.Abstractions": { "type": "Transitive", "resolved": "8.0.2", @@ -75,19 +51,6 @@ "System.Diagnostics.DiagnosticSource": "4.7.1" } }, - "Newtonsoft.Json": { - "type": "Transitive", - "resolved": "13.0.3", - "contentHash": "HrC5BXdl00IP9zeV+0Z848QWPAoCr9P3bDEZguI+gkLcBKAOxix/tLEAAHC+UvDNPv4a2d18lOReHMOagPa+zQ==" - }, - "Newtonsoft.Json.Bson": { - "type": "Transitive", - "resolved": "1.0.2", - "contentHash": "QYFyxhaABwmq3p/21VrZNYvCg3DaEoN/wUuw5nmfAf0X3HLjgupwhkEWdgfb9nvGAUIv3osmZoD3kKl4jxEmYQ==", - "dependencies": { - "Newtonsoft.Json": "12.0.1" - } - }, "Polly.Core": { "type": "Transitive", "resolved": "8.6.5", @@ -103,19 +66,50 @@ "resolved": "4.7.1", "contentHash": "j81Lovt90PDAq8kLpaJfJKV/rWdWuEk6jfV+MBkee33vzYLEUsy4gXK8laa9V2nZlLM9VM9yA/OOQxxPEJKAMw==" }, + "System.IO.Pipelines": { + "type": "Transitive", + "resolved": "9.0.12", + "contentHash": "LyvCiOzotNkRgn4wtksKjp/KEljoNtQpuAdunh6PipeyRP/qIdzmeeIjFLUaknkk237eMuYYi2YbkG0pbFBpDg==" + }, + "System.Text.Encodings.Web": { + "type": "Transitive", + "resolved": "9.0.12", + "contentHash": "T69549unMgkU+kbmDOVWYplDiJP6+b1V4NxXh/ao6ITp9xfWCeNPd/H8OI/WLxM/jjYreAVOLJaNayxtFVd7vA==" + }, + "System.Text.Json": { + "type": "Transitive", + "resolved": "9.0.12", + "contentHash": "wHv2GrfYd4/uaoZQJj6NOR8M0AlnWJ2/MFAHQomSMqk+/rSIY6AlcitL6LXbTgXf8+ngGjAAmQm17kfbNplQ9w==", + "dependencies": { + "System.IO.Pipelines": "9.0.12", + "System.Text.Encodings.Web": "9.0.12" + } + }, "ocelot": { "type": "Project", "dependencies": { "FluentValidation": "[12.1.1, )", "IPAddressRange": "[6.3.0, )", "Microsoft.AspNetCore.MiddlewareAnalysis": "[8.0.22, )", - "Microsoft.AspNetCore.Mvc.NewtonsoftJson": "[8.0.22, )", - "Microsoft.Extensions.DiagnosticAdapter": "[3.1.32, )" + "Microsoft.Extensions.DiagnosticAdapter": "[3.1.32, )", + "System.Text.Json": "[9.0.12, )" } } }, - "net8.0/osx-x64": {}, - "net8.0/win-x64": {}, + "net8.0/osx-x64": { + "System.Text.Encodings.Web": { + "type": "Transitive", + "resolved": "9.0.12", + "contentHash": "T69549unMgkU+kbmDOVWYplDiJP6+b1V4NxXh/ao6ITp9xfWCeNPd/H8OI/WLxM/jjYreAVOLJaNayxtFVd7vA==" + } + }, + "net8.0/win-x64": { + "System.Text.Encodings.Web": { + "type": "Transitive", + "resolved": "9.0.12", + "contentHash": "T69549unMgkU+kbmDOVWYplDiJP6+b1V4NxXh/ao6ITp9xfWCeNPd/H8OI/WLxM/jjYreAVOLJaNayxtFVd7vA==" + } + }, "net9.0": { "Polly": { "type": "Direct", @@ -145,15 +139,6 @@ "resolved": "6.3.0", "contentHash": "VrGoeUz+ZK2QiwHNj+vab9uOvTDucenRseJZjc4uB7ASduQ7RNWnpd8gy1e9z2BsY4VoigVaCRrcQCQKuQVSiw==" }, - "Microsoft.AspNetCore.JsonPatch": { - "type": "Transitive", - "resolved": "9.0.11", - "contentHash": "Q+A8LiyaUBurFMSdAzKTpT8jEa9Sc8EsNK0sJEA6glRP4vVl7OGXLV07bfDhcVlFU2hUkn+6Ofmw7HQ0cJ1n1g==", - "dependencies": { - "Microsoft.CSharp": "4.7.0", - "Newtonsoft.Json": "13.0.3" - } - }, "Microsoft.AspNetCore.MiddlewareAnalysis": { "type": "Transitive", "resolved": "9.0.11", @@ -162,21 +147,6 @@ "Microsoft.Extensions.DependencyInjection.Abstractions": "9.0.11" } }, - "Microsoft.AspNetCore.Mvc.NewtonsoftJson": { - "type": "Transitive", - "resolved": "9.0.11", - "contentHash": "xbpMq5ptjbTivpGz76NQ80Z3Oy204ndTJGoUdQB+vF0DOoii/loz1gr/q2KdFdloAFXju0v4lTiWEhGcIKmtyQ==", - "dependencies": { - "Microsoft.AspNetCore.JsonPatch": "9.0.11", - "Newtonsoft.Json": "13.0.3", - "Newtonsoft.Json.Bson": "1.0.2" - } - }, - "Microsoft.CSharp": { - "type": "Transitive", - "resolved": "4.7.0", - "contentHash": "pTj+D3uJWyN3My70i2Hqo+OXixq3Os2D1nJ2x92FFo6sk8fYS1m1WLNTs0Dc1uPaViH0YvEEwvzddQ7y4rhXmA==" - }, "Microsoft.Extensions.DependencyInjection.Abstractions": { "type": "Transitive", "resolved": "9.0.11", @@ -190,19 +160,6 @@ "System.Diagnostics.DiagnosticSource": "4.7.1" } }, - "Newtonsoft.Json": { - "type": "Transitive", - "resolved": "13.0.3", - "contentHash": "HrC5BXdl00IP9zeV+0Z848QWPAoCr9P3bDEZguI+gkLcBKAOxix/tLEAAHC+UvDNPv4a2d18lOReHMOagPa+zQ==" - }, - "Newtonsoft.Json.Bson": { - "type": "Transitive", - "resolved": "1.0.2", - "contentHash": "QYFyxhaABwmq3p/21VrZNYvCg3DaEoN/wUuw5nmfAf0X3HLjgupwhkEWdgfb9nvGAUIv3osmZoD3kKl4jxEmYQ==", - "dependencies": { - "Newtonsoft.Json": "12.0.1" - } - }, "Polly.Core": { "type": "Transitive", "resolved": "8.6.5", @@ -218,14 +175,19 @@ "resolved": "4.7.1", "contentHash": "j81Lovt90PDAq8kLpaJfJKV/rWdWuEk6jfV+MBkee33vzYLEUsy4gXK8laa9V2nZlLM9VM9yA/OOQxxPEJKAMw==" }, + "System.Text.Json": { + "type": "Transitive", + "resolved": "9.0.12", + "contentHash": "wHv2GrfYd4/uaoZQJj6NOR8M0AlnWJ2/MFAHQomSMqk+/rSIY6AlcitL6LXbTgXf8+ngGjAAmQm17kfbNplQ9w==" + }, "ocelot": { "type": "Project", "dependencies": { "FluentValidation": "[12.1.1, )", "IPAddressRange": "[6.3.0, )", "Microsoft.AspNetCore.MiddlewareAnalysis": "[9.0.11, )", - "Microsoft.AspNetCore.Mvc.NewtonsoftJson": "[9.0.11, )", - "Microsoft.Extensions.DiagnosticAdapter": "[3.1.32, )" + "Microsoft.Extensions.DiagnosticAdapter": "[3.1.32, )", + "System.Text.Json": "[9.0.12, )" } } }, diff --git a/src/Ocelot.Tracing.Butterfly/packages.lock.json b/src/Ocelot.Tracing.Butterfly/packages.lock.json index bef305d94..2fcae9619 100644 --- a/src/Ocelot.Tracing.Butterfly/packages.lock.json +++ b/src/Ocelot.Tracing.Butterfly/packages.lock.json @@ -169,15 +169,6 @@ "Microsoft.Extensions.Primitives": "2.0.0" } }, - "Microsoft.AspNetCore.JsonPatch": { - "type": "Transitive", - "resolved": "8.0.22", - "contentHash": "gquk+JFVSXMJSHP/wWBgF6gYrwk616T6uJPaXvdXxBTRe43KTzuW0M+eMVlJsDH/lHGvItdjv47Y6uJ7WQVoSg==", - "dependencies": { - "Microsoft.CSharp": "4.7.0", - "Newtonsoft.Json": "13.0.3" - } - }, "Microsoft.AspNetCore.MiddlewareAnalysis": { "type": "Transitive", "resolved": "8.0.22", @@ -195,16 +186,6 @@ "Microsoft.Net.Http.Headers": "2.0.0" } }, - "Microsoft.AspNetCore.Mvc.NewtonsoftJson": { - "type": "Transitive", - "resolved": "8.0.22", - "contentHash": "jSMF5XkqtWvFyvyVJFKrgmGhMh1sDKzIHa+S4WVXa1AY/F0Wou+uFbjO1DPlHt/TWdsWhuhVI1nF0yqIgxRrKQ==", - "dependencies": { - "Microsoft.AspNetCore.JsonPatch": "8.0.22", - "Newtonsoft.Json": "13.0.3", - "Newtonsoft.Json.Bson": "1.0.2" - } - }, "Microsoft.AspNetCore.Routing.Abstractions": { "type": "Transitive", "resolved": "2.0.0", @@ -215,8 +196,26 @@ }, "Microsoft.CSharp": { "type": "Transitive", - "resolved": "4.7.0", - "contentHash": "pTj+D3uJWyN3My70i2Hqo+OXixq3Os2D1nJ2x92FFo6sk8fYS1m1WLNTs0Dc1uPaViH0YvEEwvzddQ7y4rhXmA==" + "resolved": "4.3.0", + "contentHash": "P+MBhIM0YX+JqROuf7i306ZLJEjQYA9uUyRDE+OqwUI5sh41e2ZbPQV3LfAPh+29cmceE1pUffXsGfR4eMY3KA==", + "dependencies": { + "System.Collections": "4.3.0", + "System.Diagnostics.Debug": "4.3.0", + "System.Dynamic.Runtime": "4.3.0", + "System.Globalization": "4.3.0", + "System.Linq": "4.3.0", + "System.Linq.Expressions": "4.3.0", + "System.ObjectModel": "4.3.0", + "System.Reflection": "4.3.0", + "System.Reflection.Extensions": "4.3.0", + "System.Reflection.Primitives": "4.3.0", + "System.Reflection.TypeExtensions": "4.3.0", + "System.Resources.ResourceManager": "4.3.0", + "System.Runtime": "4.3.0", + "System.Runtime.Extensions": "4.3.0", + "System.Runtime.InteropServices": "4.3.0", + "System.Threading": "4.3.0" + } }, "Microsoft.Extensions.Configuration": { "type": "Transitive", @@ -391,15 +390,15 @@ }, "Newtonsoft.Json": { "type": "Transitive", - "resolved": "13.0.3", - "contentHash": "HrC5BXdl00IP9zeV+0Z848QWPAoCr9P3bDEZguI+gkLcBKAOxix/tLEAAHC+UvDNPv4a2d18lOReHMOagPa+zQ==" - }, - "Newtonsoft.Json.Bson": { - "type": "Transitive", - "resolved": "1.0.2", - "contentHash": "QYFyxhaABwmq3p/21VrZNYvCg3DaEoN/wUuw5nmfAf0X3HLjgupwhkEWdgfb9nvGAUIv3osmZoD3kKl4jxEmYQ==", + "resolved": "10.0.3", + "contentHash": "hSXaFmh7hNCuEoC4XNY5DrRkLDzYHqPx/Ik23R4J86Z7PE/Y6YidhG602dFVdLBRSdG6xp9NabH3dXpcoxWvww==", "dependencies": { - "Newtonsoft.Json": "12.0.1" + "Microsoft.CSharp": "4.3.0", + "NETStandard.Library": "1.6.1", + "System.ComponentModel.TypeConverter": "4.3.0", + "System.Runtime.Serialization.Formatters": "4.3.0", + "System.Runtime.Serialization.Primitives": "4.3.0", + "System.Xml.XmlDocument": "4.3.0" } }, "runtime.debian.8-x64.runtime.native.System.Security.Cryptography.OpenSsl": { @@ -554,6 +553,33 @@ "System.Threading.Tasks": "4.3.0" } }, + "System.Collections.NonGeneric": { + "type": "Transitive", + "resolved": "4.3.0", + "contentHash": "prtjIEMhGUnQq6RnPEYLpFt8AtLbp9yq2zxOSrY7KJJZrw25Fi97IzBqY7iqssbM61Ek5b8f3MG/sG1N2sN5KA==", + "dependencies": { + "System.Diagnostics.Debug": "4.3.0", + "System.Globalization": "4.3.0", + "System.Resources.ResourceManager": "4.3.0", + "System.Runtime": "4.3.0", + "System.Runtime.Extensions": "4.3.0", + "System.Threading": "4.3.0" + } + }, + "System.Collections.Specialized": { + "type": "Transitive", + "resolved": "4.3.0", + "contentHash": "Epx8PoVZR0iuOnJJDzp7pWvdfMMOAvpUo95pC4ScH2mJuXkKA2Y4aR3cG9qt2klHgSons1WFh4kcGW7cSXvrxg==", + "dependencies": { + "System.Collections.NonGeneric": "4.3.0", + "System.Globalization": "4.3.0", + "System.Globalization.Extensions": "4.3.0", + "System.Resources.ResourceManager": "4.3.0", + "System.Runtime": "4.3.0", + "System.Runtime.Extensions": "4.3.0", + "System.Threading": "4.3.0" + } + }, "System.ComponentModel": { "type": "Transitive", "resolved": "4.3.0", @@ -562,6 +588,38 @@ "System.Runtime": "4.3.0" } }, + "System.ComponentModel.Primitives": { + "type": "Transitive", + "resolved": "4.3.0", + "contentHash": "j8GUkCpM8V4d4vhLIIoBLGey2Z5bCkMVNjEZseyAlm4n5arcsJOeI3zkUP+zvZgzsbLTYh4lYeP/ZD/gdIAPrw==", + "dependencies": { + "System.ComponentModel": "4.3.0", + "System.Resources.ResourceManager": "4.3.0", + "System.Runtime": "4.3.0" + } + }, + "System.ComponentModel.TypeConverter": { + "type": "Transitive", + "resolved": "4.3.0", + "contentHash": "16pQ6P+EdhcXzPiEK4kbA953Fu0MNG2ovxTZU81/qsCd1zPRsKc3uif5NgvllCY598k6bI0KUyKW8fanlfaDQg==", + "dependencies": { + "System.Collections": "4.3.0", + "System.Collections.NonGeneric": "4.3.0", + "System.Collections.Specialized": "4.3.0", + "System.ComponentModel": "4.3.0", + "System.ComponentModel.Primitives": "4.3.0", + "System.Globalization": "4.3.0", + "System.Linq": "4.3.0", + "System.Reflection": "4.3.0", + "System.Reflection.Extensions": "4.3.0", + "System.Reflection.Primitives": "4.3.0", + "System.Reflection.TypeExtensions": "4.3.0", + "System.Resources.ResourceManager": "4.3.0", + "System.Runtime": "4.3.0", + "System.Runtime.Extensions": "4.3.0", + "System.Threading": "4.3.0" + } + }, "System.Console": { "type": "Transitive", "resolved": "4.3.0", @@ -609,6 +667,27 @@ "System.Runtime": "4.3.0" } }, + "System.Dynamic.Runtime": { + "type": "Transitive", + "resolved": "4.3.0", + "contentHash": "SNVi1E/vfWUAs/WYKhE9+qlS6KqK0YVhnlT0HQtr8pMIA8YX3lwy3uPMownDwdYISBdmAF/2holEIldVp85Wag==", + "dependencies": { + "System.Collections": "4.3.0", + "System.Diagnostics.Debug": "4.3.0", + "System.Linq": "4.3.0", + "System.Linq.Expressions": "4.3.0", + "System.ObjectModel": "4.3.0", + "System.Reflection": "4.3.0", + "System.Reflection.Emit": "4.3.0", + "System.Reflection.Emit.ILGeneration": "4.3.0", + "System.Reflection.Primitives": "4.3.0", + "System.Reflection.TypeExtensions": "4.3.0", + "System.Resources.ResourceManager": "4.3.0", + "System.Runtime": "4.3.0", + "System.Runtime.Extensions": "4.3.0", + "System.Threading": "4.3.0" + } + }, "System.Globalization": { "type": "Transitive", "resolved": "4.3.0", @@ -716,6 +795,11 @@ "System.Runtime": "4.3.0" } }, + "System.IO.Pipelines": { + "type": "Transitive", + "resolved": "9.0.12", + "contentHash": "LyvCiOzotNkRgn4wtksKjp/KEljoNtQpuAdunh6PipeyRP/qIdzmeeIjFLUaknkk237eMuYYi2YbkG0pbFBpDg==" + }, "System.Linq": { "type": "Transitive", "resolved": "4.3.0", @@ -980,6 +1064,18 @@ "System.Runtime.Extensions": "4.3.0" } }, + "System.Runtime.Serialization.Formatters": { + "type": "Transitive", + "resolved": "4.3.0", + "contentHash": "KT591AkTNFOTbhZlaeMVvfax3RqhH1EJlcwF50Wm7sfnBLuHiOeZRRKrr1ns3NESkM20KPZ5Ol/ueMq5vg4QoQ==", + "dependencies": { + "System.Collections": "4.3.0", + "System.Reflection": "4.3.0", + "System.Resources.ResourceManager": "4.3.0", + "System.Runtime": "4.3.0", + "System.Runtime.Serialization.Primitives": "4.3.0" + } + }, "System.Runtime.Serialization.Primitives": { "type": "Transitive", "resolved": "4.3.0", @@ -1156,8 +1252,17 @@ }, "System.Text.Encodings.Web": { "type": "Transitive", - "resolved": "4.4.0", - "contentHash": "l/tYeikqMHX2MD2jzrHDfR9ejrpTTF7wvAEbR51AMvzip1wSJgiURbDik4iv/w7ZgytmTD/hlwpplEhF9bmFNw==" + "resolved": "9.0.12", + "contentHash": "T69549unMgkU+kbmDOVWYplDiJP6+b1V4NxXh/ao6ITp9xfWCeNPd/H8OI/WLxM/jjYreAVOLJaNayxtFVd7vA==" + }, + "System.Text.Json": { + "type": "Transitive", + "resolved": "9.0.12", + "contentHash": "wHv2GrfYd4/uaoZQJj6NOR8M0AlnWJ2/MFAHQomSMqk+/rSIY6AlcitL6LXbTgXf8+ngGjAAmQm17kfbNplQ9w==", + "dependencies": { + "System.IO.Pipelines": "9.0.12", + "System.Text.Encodings.Web": "9.0.12" + } }, "System.Text.RegularExpressions": { "type": "Transitive", @@ -1257,14 +1362,31 @@ "System.Xml.ReaderWriter": "4.3.0" } }, + "System.Xml.XmlDocument": { + "type": "Transitive", + "resolved": "4.3.0", + "contentHash": "lJ8AxvkX7GQxpC6GFCeBj8ThYVyQczx2+f/cWHJU8tjS7YfI6Cv6bon70jVEgs2CiFbmmM8b9j1oZVx0dSI2Ww==", + "dependencies": { + "System.Collections": "4.3.0", + "System.Diagnostics.Debug": "4.3.0", + "System.Globalization": "4.3.0", + "System.IO": "4.3.0", + "System.Resources.ResourceManager": "4.3.0", + "System.Runtime": "4.3.0", + "System.Runtime.Extensions": "4.3.0", + "System.Text.Encoding": "4.3.0", + "System.Threading": "4.3.0", + "System.Xml.ReaderWriter": "4.3.0" + } + }, "ocelot": { "type": "Project", "dependencies": { "FluentValidation": "[12.1.1, )", "IPAddressRange": "[6.3.0, )", "Microsoft.AspNetCore.MiddlewareAnalysis": "[8.0.22, )", - "Microsoft.AspNetCore.Mvc.NewtonsoftJson": "[8.0.22, )", - "Microsoft.Extensions.DiagnosticAdapter": "[3.1.32, )" + "Microsoft.Extensions.DiagnosticAdapter": "[3.1.32, )", + "System.Text.Json": "[9.0.12, )" } } }, @@ -2085,6 +2207,11 @@ "runtime.any.System.Text.Encoding.Extensions": "4.3.0" } }, + "System.Text.Encodings.Web": { + "type": "Transitive", + "resolved": "9.0.12", + "contentHash": "T69549unMgkU+kbmDOVWYplDiJP6+b1V4NxXh/ao6ITp9xfWCeNPd/H8OI/WLxM/jjYreAVOLJaNayxtFVd7vA==" + }, "System.Threading.Tasks": { "type": "Transitive", "resolved": "4.3.0", @@ -2915,6 +3042,11 @@ "runtime.any.System.Text.Encoding.Extensions": "4.3.0" } }, + "System.Text.Encodings.Web": { + "type": "Transitive", + "resolved": "9.0.12", + "contentHash": "T69549unMgkU+kbmDOVWYplDiJP6+b1V4NxXh/ao6ITp9xfWCeNPd/H8OI/WLxM/jjYreAVOLJaNayxtFVd7vA==" + }, "System.Threading.Overlapped": { "type": "Transitive", "resolved": "4.3.0", @@ -3117,15 +3249,6 @@ "Microsoft.Extensions.Primitives": "2.0.0" } }, - "Microsoft.AspNetCore.JsonPatch": { - "type": "Transitive", - "resolved": "9.0.11", - "contentHash": "Q+A8LiyaUBurFMSdAzKTpT8jEa9Sc8EsNK0sJEA6glRP4vVl7OGXLV07bfDhcVlFU2hUkn+6Ofmw7HQ0cJ1n1g==", - "dependencies": { - "Microsoft.CSharp": "4.7.0", - "Newtonsoft.Json": "13.0.3" - } - }, "Microsoft.AspNetCore.MiddlewareAnalysis": { "type": "Transitive", "resolved": "9.0.11", @@ -3143,16 +3266,6 @@ "Microsoft.Net.Http.Headers": "2.0.0" } }, - "Microsoft.AspNetCore.Mvc.NewtonsoftJson": { - "type": "Transitive", - "resolved": "9.0.11", - "contentHash": "xbpMq5ptjbTivpGz76NQ80Z3Oy204ndTJGoUdQB+vF0DOoii/loz1gr/q2KdFdloAFXju0v4lTiWEhGcIKmtyQ==", - "dependencies": { - "Microsoft.AspNetCore.JsonPatch": "9.0.11", - "Newtonsoft.Json": "13.0.3", - "Newtonsoft.Json.Bson": "1.0.2" - } - }, "Microsoft.AspNetCore.Routing.Abstractions": { "type": "Transitive", "resolved": "2.0.0", @@ -3163,8 +3276,26 @@ }, "Microsoft.CSharp": { "type": "Transitive", - "resolved": "4.7.0", - "contentHash": "pTj+D3uJWyN3My70i2Hqo+OXixq3Os2D1nJ2x92FFo6sk8fYS1m1WLNTs0Dc1uPaViH0YvEEwvzddQ7y4rhXmA==" + "resolved": "4.3.0", + "contentHash": "P+MBhIM0YX+JqROuf7i306ZLJEjQYA9uUyRDE+OqwUI5sh41e2ZbPQV3LfAPh+29cmceE1pUffXsGfR4eMY3KA==", + "dependencies": { + "System.Collections": "4.3.0", + "System.Diagnostics.Debug": "4.3.0", + "System.Dynamic.Runtime": "4.3.0", + "System.Globalization": "4.3.0", + "System.Linq": "4.3.0", + "System.Linq.Expressions": "4.3.0", + "System.ObjectModel": "4.3.0", + "System.Reflection": "4.3.0", + "System.Reflection.Extensions": "4.3.0", + "System.Reflection.Primitives": "4.3.0", + "System.Reflection.TypeExtensions": "4.3.0", + "System.Resources.ResourceManager": "4.3.0", + "System.Runtime": "4.3.0", + "System.Runtime.Extensions": "4.3.0", + "System.Runtime.InteropServices": "4.3.0", + "System.Threading": "4.3.0" + } }, "Microsoft.Extensions.Configuration": { "type": "Transitive", @@ -3339,15 +3470,15 @@ }, "Newtonsoft.Json": { "type": "Transitive", - "resolved": "13.0.3", - "contentHash": "HrC5BXdl00IP9zeV+0Z848QWPAoCr9P3bDEZguI+gkLcBKAOxix/tLEAAHC+UvDNPv4a2d18lOReHMOagPa+zQ==" - }, - "Newtonsoft.Json.Bson": { - "type": "Transitive", - "resolved": "1.0.2", - "contentHash": "QYFyxhaABwmq3p/21VrZNYvCg3DaEoN/wUuw5nmfAf0X3HLjgupwhkEWdgfb9nvGAUIv3osmZoD3kKl4jxEmYQ==", + "resolved": "10.0.3", + "contentHash": "hSXaFmh7hNCuEoC4XNY5DrRkLDzYHqPx/Ik23R4J86Z7PE/Y6YidhG602dFVdLBRSdG6xp9NabH3dXpcoxWvww==", "dependencies": { - "Newtonsoft.Json": "12.0.1" + "Microsoft.CSharp": "4.3.0", + "NETStandard.Library": "1.6.1", + "System.ComponentModel.TypeConverter": "4.3.0", + "System.Runtime.Serialization.Formatters": "4.3.0", + "System.Runtime.Serialization.Primitives": "4.3.0", + "System.Xml.XmlDocument": "4.3.0" } }, "runtime.debian.8-x64.runtime.native.System.Security.Cryptography.OpenSsl": { @@ -3502,6 +3633,33 @@ "System.Threading.Tasks": "4.3.0" } }, + "System.Collections.NonGeneric": { + "type": "Transitive", + "resolved": "4.3.0", + "contentHash": "prtjIEMhGUnQq6RnPEYLpFt8AtLbp9yq2zxOSrY7KJJZrw25Fi97IzBqY7iqssbM61Ek5b8f3MG/sG1N2sN5KA==", + "dependencies": { + "System.Diagnostics.Debug": "4.3.0", + "System.Globalization": "4.3.0", + "System.Resources.ResourceManager": "4.3.0", + "System.Runtime": "4.3.0", + "System.Runtime.Extensions": "4.3.0", + "System.Threading": "4.3.0" + } + }, + "System.Collections.Specialized": { + "type": "Transitive", + "resolved": "4.3.0", + "contentHash": "Epx8PoVZR0iuOnJJDzp7pWvdfMMOAvpUo95pC4ScH2mJuXkKA2Y4aR3cG9qt2klHgSons1WFh4kcGW7cSXvrxg==", + "dependencies": { + "System.Collections.NonGeneric": "4.3.0", + "System.Globalization": "4.3.0", + "System.Globalization.Extensions": "4.3.0", + "System.Resources.ResourceManager": "4.3.0", + "System.Runtime": "4.3.0", + "System.Runtime.Extensions": "4.3.0", + "System.Threading": "4.3.0" + } + }, "System.ComponentModel": { "type": "Transitive", "resolved": "4.3.0", @@ -3510,6 +3668,38 @@ "System.Runtime": "4.3.0" } }, + "System.ComponentModel.Primitives": { + "type": "Transitive", + "resolved": "4.3.0", + "contentHash": "j8GUkCpM8V4d4vhLIIoBLGey2Z5bCkMVNjEZseyAlm4n5arcsJOeI3zkUP+zvZgzsbLTYh4lYeP/ZD/gdIAPrw==", + "dependencies": { + "System.ComponentModel": "4.3.0", + "System.Resources.ResourceManager": "4.3.0", + "System.Runtime": "4.3.0" + } + }, + "System.ComponentModel.TypeConverter": { + "type": "Transitive", + "resolved": "4.3.0", + "contentHash": "16pQ6P+EdhcXzPiEK4kbA953Fu0MNG2ovxTZU81/qsCd1zPRsKc3uif5NgvllCY598k6bI0KUyKW8fanlfaDQg==", + "dependencies": { + "System.Collections": "4.3.0", + "System.Collections.NonGeneric": "4.3.0", + "System.Collections.Specialized": "4.3.0", + "System.ComponentModel": "4.3.0", + "System.ComponentModel.Primitives": "4.3.0", + "System.Globalization": "4.3.0", + "System.Linq": "4.3.0", + "System.Reflection": "4.3.0", + "System.Reflection.Extensions": "4.3.0", + "System.Reflection.Primitives": "4.3.0", + "System.Reflection.TypeExtensions": "4.3.0", + "System.Resources.ResourceManager": "4.3.0", + "System.Runtime": "4.3.0", + "System.Runtime.Extensions": "4.3.0", + "System.Threading": "4.3.0" + } + }, "System.Console": { "type": "Transitive", "resolved": "4.3.0", @@ -3557,6 +3747,27 @@ "System.Runtime": "4.3.0" } }, + "System.Dynamic.Runtime": { + "type": "Transitive", + "resolved": "4.3.0", + "contentHash": "SNVi1E/vfWUAs/WYKhE9+qlS6KqK0YVhnlT0HQtr8pMIA8YX3lwy3uPMownDwdYISBdmAF/2holEIldVp85Wag==", + "dependencies": { + "System.Collections": "4.3.0", + "System.Diagnostics.Debug": "4.3.0", + "System.Linq": "4.3.0", + "System.Linq.Expressions": "4.3.0", + "System.ObjectModel": "4.3.0", + "System.Reflection": "4.3.0", + "System.Reflection.Emit": "4.3.0", + "System.Reflection.Emit.ILGeneration": "4.3.0", + "System.Reflection.Primitives": "4.3.0", + "System.Reflection.TypeExtensions": "4.3.0", + "System.Resources.ResourceManager": "4.3.0", + "System.Runtime": "4.3.0", + "System.Runtime.Extensions": "4.3.0", + "System.Threading": "4.3.0" + } + }, "System.Globalization": { "type": "Transitive", "resolved": "4.3.0", @@ -3928,6 +4139,18 @@ "System.Runtime.Extensions": "4.3.0" } }, + "System.Runtime.Serialization.Formatters": { + "type": "Transitive", + "resolved": "4.3.0", + "contentHash": "KT591AkTNFOTbhZlaeMVvfax3RqhH1EJlcwF50Wm7sfnBLuHiOeZRRKrr1ns3NESkM20KPZ5Ol/ueMq5vg4QoQ==", + "dependencies": { + "System.Collections": "4.3.0", + "System.Reflection": "4.3.0", + "System.Resources.ResourceManager": "4.3.0", + "System.Runtime": "4.3.0", + "System.Runtime.Serialization.Primitives": "4.3.0" + } + }, "System.Runtime.Serialization.Primitives": { "type": "Transitive", "resolved": "4.3.0", @@ -4107,6 +4330,11 @@ "resolved": "4.4.0", "contentHash": "l/tYeikqMHX2MD2jzrHDfR9ejrpTTF7wvAEbR51AMvzip1wSJgiURbDik4iv/w7ZgytmTD/hlwpplEhF9bmFNw==" }, + "System.Text.Json": { + "type": "Transitive", + "resolved": "9.0.12", + "contentHash": "wHv2GrfYd4/uaoZQJj6NOR8M0AlnWJ2/MFAHQomSMqk+/rSIY6AlcitL6LXbTgXf8+ngGjAAmQm17kfbNplQ9w==" + }, "System.Text.RegularExpressions": { "type": "Transitive", "resolved": "4.3.0", @@ -4205,14 +4433,31 @@ "System.Xml.ReaderWriter": "4.3.0" } }, + "System.Xml.XmlDocument": { + "type": "Transitive", + "resolved": "4.3.0", + "contentHash": "lJ8AxvkX7GQxpC6GFCeBj8ThYVyQczx2+f/cWHJU8tjS7YfI6Cv6bon70jVEgs2CiFbmmM8b9j1oZVx0dSI2Ww==", + "dependencies": { + "System.Collections": "4.3.0", + "System.Diagnostics.Debug": "4.3.0", + "System.Globalization": "4.3.0", + "System.IO": "4.3.0", + "System.Resources.ResourceManager": "4.3.0", + "System.Runtime": "4.3.0", + "System.Runtime.Extensions": "4.3.0", + "System.Text.Encoding": "4.3.0", + "System.Threading": "4.3.0", + "System.Xml.ReaderWriter": "4.3.0" + } + }, "ocelot": { "type": "Project", "dependencies": { "FluentValidation": "[12.1.1, )", "IPAddressRange": "[6.3.0, )", "Microsoft.AspNetCore.MiddlewareAnalysis": "[9.0.11, )", - "Microsoft.AspNetCore.Mvc.NewtonsoftJson": "[9.0.11, )", - "Microsoft.Extensions.DiagnosticAdapter": "[3.1.32, )" + "Microsoft.Extensions.DiagnosticAdapter": "[3.1.32, )", + "System.Text.Json": "[9.0.12, )" } } }, diff --git a/src/Ocelot.Tracing.OpenTracing/packages.lock.json b/src/Ocelot.Tracing.OpenTracing/packages.lock.json index c5d79df91..8a2100e45 100644 --- a/src/Ocelot.Tracing.OpenTracing/packages.lock.json +++ b/src/Ocelot.Tracing.OpenTracing/packages.lock.json @@ -27,15 +27,6 @@ "resolved": "6.3.0", "contentHash": "VrGoeUz+ZK2QiwHNj+vab9uOvTDucenRseJZjc4uB7ASduQ7RNWnpd8gy1e9z2BsY4VoigVaCRrcQCQKuQVSiw==" }, - "Microsoft.AspNetCore.JsonPatch": { - "type": "Transitive", - "resolved": "8.0.22", - "contentHash": "gquk+JFVSXMJSHP/wWBgF6gYrwk616T6uJPaXvdXxBTRe43KTzuW0M+eMVlJsDH/lHGvItdjv47Y6uJ7WQVoSg==", - "dependencies": { - "Microsoft.CSharp": "4.7.0", - "Newtonsoft.Json": "13.0.3" - } - }, "Microsoft.AspNetCore.MiddlewareAnalysis": { "type": "Transitive", "resolved": "8.0.22", @@ -44,21 +35,6 @@ "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.2" } }, - "Microsoft.AspNetCore.Mvc.NewtonsoftJson": { - "type": "Transitive", - "resolved": "8.0.22", - "contentHash": "jSMF5XkqtWvFyvyVJFKrgmGhMh1sDKzIHa+S4WVXa1AY/F0Wou+uFbjO1DPlHt/TWdsWhuhVI1nF0yqIgxRrKQ==", - "dependencies": { - "Microsoft.AspNetCore.JsonPatch": "8.0.22", - "Newtonsoft.Json": "13.0.3", - "Newtonsoft.Json.Bson": "1.0.2" - } - }, - "Microsoft.CSharp": { - "type": "Transitive", - "resolved": "4.7.0", - "contentHash": "pTj+D3uJWyN3My70i2Hqo+OXixq3Os2D1nJ2x92FFo6sk8fYS1m1WLNTs0Dc1uPaViH0YvEEwvzddQ7y4rhXmA==" - }, "Microsoft.Extensions.DependencyInjection.Abstractions": { "type": "Transitive", "resolved": "8.0.2", @@ -72,19 +48,6 @@ "System.Diagnostics.DiagnosticSource": "4.7.1" } }, - "Newtonsoft.Json": { - "type": "Transitive", - "resolved": "13.0.3", - "contentHash": "HrC5BXdl00IP9zeV+0Z848QWPAoCr9P3bDEZguI+gkLcBKAOxix/tLEAAHC+UvDNPv4a2d18lOReHMOagPa+zQ==" - }, - "Newtonsoft.Json.Bson": { - "type": "Transitive", - "resolved": "1.0.2", - "contentHash": "QYFyxhaABwmq3p/21VrZNYvCg3DaEoN/wUuw5nmfAf0X3HLjgupwhkEWdgfb9nvGAUIv3osmZoD3kKl4jxEmYQ==", - "dependencies": { - "Newtonsoft.Json": "12.0.1" - } - }, "StyleCop.Analyzers.Unstable": { "type": "Transitive", "resolved": "1.2.0.556", @@ -95,14 +58,33 @@ "resolved": "4.7.1", "contentHash": "j81Lovt90PDAq8kLpaJfJKV/rWdWuEk6jfV+MBkee33vzYLEUsy4gXK8laa9V2nZlLM9VM9yA/OOQxxPEJKAMw==" }, + "System.IO.Pipelines": { + "type": "Transitive", + "resolved": "9.0.12", + "contentHash": "LyvCiOzotNkRgn4wtksKjp/KEljoNtQpuAdunh6PipeyRP/qIdzmeeIjFLUaknkk237eMuYYi2YbkG0pbFBpDg==" + }, + "System.Text.Encodings.Web": { + "type": "Transitive", + "resolved": "9.0.12", + "contentHash": "T69549unMgkU+kbmDOVWYplDiJP6+b1V4NxXh/ao6ITp9xfWCeNPd/H8OI/WLxM/jjYreAVOLJaNayxtFVd7vA==" + }, + "System.Text.Json": { + "type": "Transitive", + "resolved": "9.0.12", + "contentHash": "wHv2GrfYd4/uaoZQJj6NOR8M0AlnWJ2/MFAHQomSMqk+/rSIY6AlcitL6LXbTgXf8+ngGjAAmQm17kfbNplQ9w==", + "dependencies": { + "System.IO.Pipelines": "9.0.12", + "System.Text.Encodings.Web": "9.0.12" + } + }, "ocelot": { "type": "Project", "dependencies": { "FluentValidation": "[12.1.1, )", "IPAddressRange": "[6.3.0, )", "Microsoft.AspNetCore.MiddlewareAnalysis": "[8.0.22, )", - "Microsoft.AspNetCore.Mvc.NewtonsoftJson": "[8.0.22, )", - "Microsoft.Extensions.DiagnosticAdapter": "[3.1.32, )" + "Microsoft.Extensions.DiagnosticAdapter": "[3.1.32, )", + "System.Text.Json": "[9.0.12, )" } } }, @@ -132,15 +114,6 @@ "resolved": "6.3.0", "contentHash": "VrGoeUz+ZK2QiwHNj+vab9uOvTDucenRseJZjc4uB7ASduQ7RNWnpd8gy1e9z2BsY4VoigVaCRrcQCQKuQVSiw==" }, - "Microsoft.AspNetCore.JsonPatch": { - "type": "Transitive", - "resolved": "9.0.11", - "contentHash": "Q+A8LiyaUBurFMSdAzKTpT8jEa9Sc8EsNK0sJEA6glRP4vVl7OGXLV07bfDhcVlFU2hUkn+6Ofmw7HQ0cJ1n1g==", - "dependencies": { - "Microsoft.CSharp": "4.7.0", - "Newtonsoft.Json": "13.0.3" - } - }, "Microsoft.AspNetCore.MiddlewareAnalysis": { "type": "Transitive", "resolved": "9.0.11", @@ -149,21 +122,6 @@ "Microsoft.Extensions.DependencyInjection.Abstractions": "9.0.11" } }, - "Microsoft.AspNetCore.Mvc.NewtonsoftJson": { - "type": "Transitive", - "resolved": "9.0.11", - "contentHash": "xbpMq5ptjbTivpGz76NQ80Z3Oy204ndTJGoUdQB+vF0DOoii/loz1gr/q2KdFdloAFXju0v4lTiWEhGcIKmtyQ==", - "dependencies": { - "Microsoft.AspNetCore.JsonPatch": "9.0.11", - "Newtonsoft.Json": "13.0.3", - "Newtonsoft.Json.Bson": "1.0.2" - } - }, - "Microsoft.CSharp": { - "type": "Transitive", - "resolved": "4.7.0", - "contentHash": "pTj+D3uJWyN3My70i2Hqo+OXixq3Os2D1nJ2x92FFo6sk8fYS1m1WLNTs0Dc1uPaViH0YvEEwvzddQ7y4rhXmA==" - }, "Microsoft.Extensions.DependencyInjection.Abstractions": { "type": "Transitive", "resolved": "9.0.11", @@ -177,19 +135,6 @@ "System.Diagnostics.DiagnosticSource": "4.7.1" } }, - "Newtonsoft.Json": { - "type": "Transitive", - "resolved": "13.0.3", - "contentHash": "HrC5BXdl00IP9zeV+0Z848QWPAoCr9P3bDEZguI+gkLcBKAOxix/tLEAAHC+UvDNPv4a2d18lOReHMOagPa+zQ==" - }, - "Newtonsoft.Json.Bson": { - "type": "Transitive", - "resolved": "1.0.2", - "contentHash": "QYFyxhaABwmq3p/21VrZNYvCg3DaEoN/wUuw5nmfAf0X3HLjgupwhkEWdgfb9nvGAUIv3osmZoD3kKl4jxEmYQ==", - "dependencies": { - "Newtonsoft.Json": "12.0.1" - } - }, "StyleCop.Analyzers.Unstable": { "type": "Transitive", "resolved": "1.2.0.556", @@ -200,14 +145,19 @@ "resolved": "4.7.1", "contentHash": "j81Lovt90PDAq8kLpaJfJKV/rWdWuEk6jfV+MBkee33vzYLEUsy4gXK8laa9V2nZlLM9VM9yA/OOQxxPEJKAMw==" }, + "System.Text.Json": { + "type": "Transitive", + "resolved": "9.0.12", + "contentHash": "wHv2GrfYd4/uaoZQJj6NOR8M0AlnWJ2/MFAHQomSMqk+/rSIY6AlcitL6LXbTgXf8+ngGjAAmQm17kfbNplQ9w==" + }, "ocelot": { "type": "Project", "dependencies": { "FluentValidation": "[12.1.1, )", "IPAddressRange": "[6.3.0, )", "Microsoft.AspNetCore.MiddlewareAnalysis": "[9.0.11, )", - "Microsoft.AspNetCore.Mvc.NewtonsoftJson": "[9.0.11, )", - "Microsoft.Extensions.DiagnosticAdapter": "[3.1.32, )" + "Microsoft.Extensions.DiagnosticAdapter": "[3.1.32, )", + "System.Text.Json": "[9.0.12, )" } } } diff --git a/src/Ocelot/Configuration/File/FileRouteBase.cs b/src/Ocelot/Configuration/File/FileRouteBase.cs index 729be646d..9b3bf7df3 100644 --- a/src/Ocelot/Configuration/File/FileRouteBase.cs +++ b/src/Ocelot/Configuration/File/FileRouteBase.cs @@ -3,7 +3,6 @@ using Ocelot.Configuration.Creator; using System.Text.Json.Serialization; -using NewtonsoftJsonIgnore = Newtonsoft.Json.JsonIgnoreAttribute; namespace Ocelot.Configuration.File; @@ -34,7 +33,7 @@ public abstract class FileRouteBase : IRouteGrouping public IDictionary Metadata { get; set; } public FileQoSOptions QoSOptions { get; set; } public FileRateLimitByHeaderRule RateLimitOptions { get; set; } // IRouteRateLimiting - [NewtonsoftJsonIgnore, JsonIgnore] // publish the schema in version 25.1! + [JsonIgnore] // publish the schema in version 25.1! public FileRateLimiting RateLimiting { get; set; } public string ServiceName { get; set; } public string ServiceNamespace { get; set; } diff --git a/src/Ocelot/Configuration/Repository/DiskFileConfigurationRepository.cs b/src/Ocelot/Configuration/Repository/DiskFileConfigurationRepository.cs index 56933a5f2..41675e417 100644 --- a/src/Ocelot/Configuration/Repository/DiskFileConfigurationRepository.cs +++ b/src/Ocelot/Configuration/Repository/DiskFileConfigurationRepository.cs @@ -1,9 +1,10 @@ using Microsoft.AspNetCore.Hosting; -using Newtonsoft.Json; using Ocelot.Configuration.ChangeTracking; using Ocelot.Configuration.File; using Ocelot.DependencyInjection; +using Ocelot.Infrastructure; using Ocelot.Responses; +using System.Text.Json; using FileSys = System.IO.File; namespace Ocelot.Configuration.Repository; @@ -49,14 +50,14 @@ public Task> Get() jsonConfiguration = FileSys.ReadAllText(_environmentFile.FullName); } - var fileConfiguration = JsonConvert.DeserializeObject(jsonConfiguration); + var fileConfiguration = JsonSerializer.Deserialize(jsonConfiguration, OcelotSerializerOptions.Web); return Task.FromResult>(new OkResponse(fileConfiguration)); } public Task Set(FileConfiguration fileConfiguration) { - var jsonConfiguration = JsonConvert.SerializeObject(fileConfiguration, Formatting.Indented); + var jsonConfiguration = JsonSerializer.Serialize(fileConfiguration, OcelotSerializerOptions.WebWriteIndented); lock (_lock) { diff --git a/src/Ocelot/Configuration/Repository/FileConfigurationPoller.cs b/src/Ocelot/Configuration/Repository/FileConfigurationPoller.cs index b91bf6ae5..9e40de50d 100644 --- a/src/Ocelot/Configuration/Repository/FileConfigurationPoller.cs +++ b/src/Ocelot/Configuration/Repository/FileConfigurationPoller.cs @@ -1,8 +1,9 @@ using Microsoft.Extensions.Hosting; -using Newtonsoft.Json; using Ocelot.Configuration.Creator; using Ocelot.Configuration.File; +using Ocelot.Infrastructure; using Ocelot.Logging; +using System.Text.Json; namespace Ocelot.Configuration.Repository; @@ -95,7 +96,7 @@ private async Task Poll() /// hash of the config. private static string ToJson(FileConfiguration config) { - var currentHash = JsonConvert.SerializeObject(config); + var currentHash = JsonSerializer.Serialize(config, OcelotSerializerOptions.Web); return currentHash; } diff --git a/src/Ocelot/DependencyInjection/ConfigurationBuilderExtensions.cs b/src/Ocelot/DependencyInjection/ConfigurationBuilderExtensions.cs index f78c4059b..1c08b8b81 100644 --- a/src/Ocelot/DependencyInjection/ConfigurationBuilderExtensions.cs +++ b/src/Ocelot/DependencyInjection/ConfigurationBuilderExtensions.cs @@ -1,9 +1,10 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration.Memory; -using Newtonsoft.Json; using Ocelot.Configuration.File; using Ocelot.Infrastructure; +using System.Text; +using System.Text.Json; namespace Ocelot.DependencyInjection; @@ -91,8 +92,8 @@ public static IConfigurationBuilder AddOcelot(this IConfigurationBuilder builder private static IConfigurationBuilder ApplyMergeOcelotJsonOption(IConfigurationBuilder builder, MergeOcelotJson mergeTo, string json, string primaryConfigFile, bool? optional, bool? reloadOnChange) { - return mergeTo == MergeOcelotJson.ToMemory ? - builder.AddJsonStream(new MemoryStream(Encoding.UTF8.GetBytes(json))) : + return mergeTo == MergeOcelotJson.ToMemory ? + builder.AddJsonStream(new MemoryStream(Encoding.UTF8.GetBytes(json))) : AddOcelotJsonFile(builder, json, primaryConfigFile, optional, reloadOnChange); } @@ -133,8 +134,8 @@ private static string GetMergedOcelotJson(string folder, IWebHostEnvironment env } var lines = File.ReadAllText(file.FullName); - var config = JsonConvert.DeserializeObject(lines); - if (file.Name.Equals(globalFileInfo.Name, StringComparison.OrdinalIgnoreCase) && + var config = JsonSerializer.Deserialize(lines, OcelotSerializerOptions.Web); + if (file.Name.Equals(globalFileInfo.Name, StringComparison.OrdinalIgnoreCase) && file.FullName.Equals(globalFileInfo.FullName, StringComparison.OrdinalIgnoreCase)) { fileConfiguration.GlobalConfiguration = config.GlobalConfiguration; @@ -144,8 +145,8 @@ private static string GetMergedOcelotJson(string folder, IWebHostEnvironment env fileConfiguration.Routes.AddRange(config.Routes); } - return JsonConvert.SerializeObject(fileConfiguration, Formatting.Indented); - } + return JsonSerializer.Serialize(fileConfiguration, OcelotSerializerOptions.WebWriteIndented); + } /// /// Adds Ocelot configuration by ready configuration object and writes JSON to the primary configuration file.
@@ -158,11 +159,11 @@ private static string GetMergedOcelotJson(string folder, IWebHostEnvironment env /// The 2nd argument of the AddJsonFile. /// The 3rd argument of the AddJsonFile. /// An object. - public static IConfigurationBuilder AddOcelot(this IConfigurationBuilder builder, FileConfiguration fileConfiguration, + public static IConfigurationBuilder AddOcelot(this IConfigurationBuilder builder, FileConfiguration fileConfiguration, string primaryConfigFile = null, bool? optional = null, bool? reloadOnChange = null) // optional injections { - var json = JsonConvert.SerializeObject(fileConfiguration, Formatting.Indented); - return AddOcelotJsonFile(builder, json, primaryConfigFile, optional, reloadOnChange); + var json = JsonSerializer.Serialize(fileConfiguration, OcelotSerializerOptions.WebWriteIndented); + return AddOcelotJsonFile(builder, json, primaryConfigFile, optional, reloadOnChange); } /// diff --git a/src/Ocelot/DependencyInjection/OcelotBuilder.cs b/src/Ocelot/DependencyInjection/OcelotBuilder.cs index ff343fafe..8db4ae2f2 100644 --- a/src/Ocelot/DependencyInjection/OcelotBuilder.cs +++ b/src/Ocelot/DependencyInjection/OcelotBuilder.cs @@ -38,6 +38,9 @@ using Ocelot.ServiceDiscovery.Providers; using Ocelot.WebSockets; using System.Reflection; +using System.Text.Encodings.Web; +using System.Text.Json.Serialization; +using System.Text.Unicode; namespace Ocelot.DependencyInjection; @@ -147,7 +150,6 @@ public OcelotBuilder(IServiceCollection services, IConfiguration configurationRo /// /// Adds default ASP.NET services which are the minimal part of the gateway core. /// - /// Finally the builder adds Newtonsoft.Json services via the extension-method.
/// To remove these services, use custom builder in the extension-method. ///
///
@@ -157,11 +159,10 @@ public OcelotBuilder(IServiceCollection services, IConfiguration configurationRo /// -
/// - . /// - /// Warning! The following extensions being called:
+ /// Warning! The following extensions being called
/// -
/// -
- /// -
- /// - , removable. + /// - . ///
/// /// The default builder being returned by extension-method. @@ -177,7 +178,14 @@ protected IMvcCoreBuilder AddDefaultAspNetServices(IMvcCoreBuilder builder, Asse .AddApplicationPart(assembly) .AddControllersAsServices() .AddAuthorization() - .AddNewtonsoftJson(); + .AddJsonOptions(op => + { + op.JsonSerializerOptions.ReferenceHandler = ReferenceHandler.IgnoreCycles; + op.JsonSerializerOptions.NumberHandling = JsonNumberHandling.AllowReadingFromString; + op.JsonSerializerOptions.WriteIndented = false; + op.JsonSerializerOptions.PropertyNameCaseInsensitive = true; + op.JsonSerializerOptions.Encoder = JavaScriptEncoder.Create(UnicodeRanges.All); + }); } public IOcelotBuilder AddSingletonDefinedAggregator() diff --git a/src/Ocelot/Infrastructure/OcelotSerializerOptions.cs b/src/Ocelot/Infrastructure/OcelotSerializerOptions.cs new file mode 100644 index 000000000..6f40987ab --- /dev/null +++ b/src/Ocelot/Infrastructure/OcelotSerializerOptions.cs @@ -0,0 +1,109 @@ +using System.Text.Encodings.Web; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.Text.Unicode; + +namespace Ocelot.Infrastructure; + +public static class OcelotSerializerOptions +{ + public static readonly JsonSerializerOptions Web = new() + { + Encoder = JavaScriptEncoder.Create(UnicodeRanges.All), + NumberHandling = JsonNumberHandling.AllowReadingFromString, + PropertyNameCaseInsensitive = true, + ReferenceHandler = ReferenceHandler.IgnoreCycles, + WriteIndented = false, + }; + + public static readonly JsonSerializerOptions WebWriteIndented = new() + { + Encoder = JavaScriptEncoder.Create(UnicodeRanges.All), + NumberHandling = JsonNumberHandling.AllowReadingFromString, + PropertyNameCaseInsensitive = true, + ReferenceHandler = ReferenceHandler.IgnoreCycles, + WriteIndented = true, + }; + + public static List ExtractValuesFromJsonPath(this JsonDocument document, string jsonPath) + { + var root = document.RootElement; + + var pathParts = jsonPath.Trim('$', '.').Replace("[*]", "").Trim().Split('.'); + + var elements = new List(); + + TraverseJsonPath(root, pathParts, 0, elements); + + return elements; + } + + private static void TraverseJsonPath(JsonElement currentElement, string[] pathParts, int index, List elements) + { + if (index >= pathParts.Length) + { + return; + } + + var part = pathParts[index]; + + if (currentElement.ValueKind == JsonValueKind.Array) + { + foreach (var element in currentElement.EnumerateArray()) + { + if (element.ValueKind == JsonValueKind.Object) + { + if (element.TryGetProperty(part, out JsonElement nextElement)) + { + if (nextElement.ValueKind == JsonValueKind.Array) + { + TraverseJsonPath(nextElement, pathParts, 0, elements); + } + else + { + var item = nextElement.ToString(); + if (!string.IsNullOrWhiteSpace(item)) + { + elements.Add(item); + } + } + } + else + { + TraverseJsonPath(element, pathParts, index + 1, elements); + } + } + else + { + TraverseJsonPath(element, pathParts, index + 1, elements); + } + } + } + else if (currentElement.ValueKind == JsonValueKind.Object) + { + if (currentElement.TryGetProperty(part, out JsonElement nextElement)) + { + if (nextElement.ValueKind == JsonValueKind.Array) + { + TraverseJsonPath(nextElement, pathParts, index + 1, elements); + } + else + { + var item = nextElement.ToString(); + if (!string.IsNullOrWhiteSpace(item)) + { + elements.Add(item); + } + } + } + } + else + { + var item = currentElement.ToString(); + if (!string.IsNullOrWhiteSpace(item)) + { + elements.Add(item); + } + } + } +} diff --git a/src/Ocelot/Metadata/DownstreamRouteExtensions.cs b/src/Ocelot/Metadata/DownstreamRouteExtensions.cs index aa4f55553..c5e08f76e 100644 --- a/src/Ocelot/Metadata/DownstreamRouteExtensions.cs +++ b/src/Ocelot/Metadata/DownstreamRouteExtensions.cs @@ -1,4 +1,5 @@ using Ocelot.Configuration; +using Ocelot.Infrastructure; using System.Globalization; using System.Text.Json; using System.Text.Json.Nodes; @@ -68,7 +69,7 @@ public static T GetMetadata(this DownstreamRoute route, string key, T default var metadata = route?.MetadataOptions.Metadata; return (metadata == null || !metadata.TryGetValue(key, out var metadataValue) || metadataValue == null) ? defaultValue - : (T)ConvertTo(typeof(T), metadataValue, route.MetadataOptions, options ?? new(JsonSerializerDefaults.Web)); + : (T)ConvertTo(typeof(T), metadataValue, route.MetadataOptions, options ?? OcelotSerializerOptions.Web); } // TODO See Metadata sample diff --git a/src/Ocelot/Multiplexer/MultiplexingMiddleware.cs b/src/Ocelot/Multiplexer/MultiplexingMiddleware.cs index c148eb9b9..f5cce0d81 100644 --- a/src/Ocelot/Multiplexer/MultiplexingMiddleware.cs +++ b/src/Ocelot/Multiplexer/MultiplexingMiddleware.cs @@ -1,12 +1,13 @@ -using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Primitives; -using Newtonsoft.Json.Linq; using Ocelot.Configuration; using Ocelot.Configuration.File; using Ocelot.DownstreamRouteFinder.UrlMatcher; +using Ocelot.Infrastructure; using Ocelot.Logging; using Ocelot.Middleware; using System.Collections; +using System.Text.Json; using Route = Ocelot.Configuration.Route; namespace Ocelot.Multiplexer; @@ -132,14 +133,14 @@ protected virtual async Task ProcessRoutesWithRouteKeysAsync(Http { var processing = new List>(); var content = await mainResponse.Items.DownstreamResponse().Content.ReadAsStringAsync(); - var jObject = JToken.Parse(content); - + using var document = JsonDocument.Parse(content); + foreach (var downstreamRoute in routes.Skip(1)) { var matchAdvancedAgg = routeKeysConfigs.FirstOrDefault(q => q.RouteKey == downstreamRoute.Key); if (matchAdvancedAgg != null) { - processing.AddRange(ProcessRouteWithComplexAggregation(matchAdvancedAgg, jObject, context, downstreamRoute)); + processing.AddRange(ProcessRouteWithComplexAggregation(matchAdvancedAgg, document, context, downstreamRoute)); continue; } @@ -162,11 +163,14 @@ private Task MapResponsesAsync(HttpContext context, Route route, HttpContext mai /// /// Processing a route with aggregation. /// - private IEnumerable> ProcessRouteWithComplexAggregation(AggregateRouteConfig matchAdvancedAgg, - JToken jObject, HttpContext httpContext, DownstreamRoute downstreamRoute) + private IEnumerable> ProcessRouteWithComplexAggregation(AggregateRouteConfig matchAdvancedAgg, + JsonDocument document, HttpContext httpContext, DownstreamRoute downstreamRoute) { - var processing = new List>(); - var values = jObject.SelectTokens(matchAdvancedAgg.JsonPath).Select(s => s.ToString()).Distinct(); + var processing = new List>(); + + var values = document.ExtractValuesFromJsonPath(matchAdvancedAgg.JsonPath) + .Distinct(); + foreach (var value in values) { var tPnv = httpContext.Items.TemplatePlaceholderNameAndValues(); @@ -175,8 +179,8 @@ private IEnumerable> ProcessRouteWithComplexAggregation(Aggreg } return processing; - } - + } + /// /// Process a downstream route asynchronously. /// diff --git a/src/Ocelot/Ocelot.csproj b/src/Ocelot/Ocelot.csproj index 74fd7ee9e..403b69b83 100644 --- a/src/Ocelot/Ocelot.csproj +++ b/src/Ocelot/Ocelot.csproj @@ -43,6 +43,7 @@ + @@ -56,12 +57,10 @@ - - diff --git a/src/Ocelot/RateLimiting/DistributedCacheRateLimitStorage.cs b/src/Ocelot/RateLimiting/DistributedCacheRateLimitStorage.cs index 971a4982e..ad303bc9c 100644 --- a/src/Ocelot/RateLimiting/DistributedCacheRateLimitStorage.cs +++ b/src/Ocelot/RateLimiting/DistributedCacheRateLimitStorage.cs @@ -1,5 +1,6 @@ using Microsoft.Extensions.Caching.Distributed; -using Newtonsoft.Json; +using Ocelot.Infrastructure; +using System.Text.Json; namespace Ocelot.RateLimiting; @@ -16,7 +17,7 @@ public class DistributedCacheRateLimitStorage : IRateLimitStorage public DistributedCacheRateLimitStorage(IDistributedCache memoryCache) => _memoryCache = memoryCache; public void Set(string id, RateLimitCounter counter, TimeSpan expirationTime) - => _memoryCache.SetString(id, JsonConvert.SerializeObject(counter), new DistributedCacheEntryOptions().SetAbsoluteExpiration(expirationTime)); + => _memoryCache.SetString(id, JsonSerializer.Serialize(counter, OcelotSerializerOptions.Web), new DistributedCacheEntryOptions().SetAbsoluteExpiration(expirationTime)); public bool Exists(string id) => !string.IsNullOrEmpty(_memoryCache.GetString(id)); @@ -24,7 +25,7 @@ public void Set(string id, RateLimitCounter counter, TimeSpan expirationTime) { var stored = _memoryCache.GetString(id); return string.IsNullOrEmpty(stored) ? null : - JsonConvert.DeserializeObject(stored); + JsonSerializer.Deserialize(stored, OcelotSerializerOptions.Web); } public void Remove(string id) => _memoryCache.Remove(id); diff --git a/src/Ocelot/RateLimiting/RateLimitCounter.cs b/src/Ocelot/RateLimiting/RateLimitCounter.cs index f8e94c29a..780f19866 100644 --- a/src/Ocelot/RateLimiting/RateLimitCounter.cs +++ b/src/Ocelot/RateLimiting/RateLimitCounter.cs @@ -1,6 +1,5 @@ using System.Globalization; using System.Text.Json.Serialization; -using NewtonsoftJsonConstructor = Newtonsoft.Json.JsonConstructorAttribute; namespace Ocelot.RateLimiting; @@ -16,12 +15,11 @@ public RateLimitCounter(DateTime startedAt) } [JsonConstructor] - [NewtonsoftJsonConstructor] - public RateLimitCounter(DateTime startedAt, DateTime? exceededAt, long totalRequests) + public RateLimitCounter(DateTime startedAt, DateTime? exceededAt, long total) { StartedAt = startedAt; ExceededAt = exceededAt; - Total = totalRequests; + Total = total; } /// The moment when the counting was started. @@ -30,11 +28,11 @@ public RateLimitCounter(DateTime startedAt, DateTime? exceededAt, long totalRequ /// The moment when the limit was exceeded. /// A value of the moment. - public DateTime? ExceededAt; + public DateTime? ExceededAt { get; set; } /// Total number of requests counted. /// A value of total number. - public long Total; + public long Total { get; set; } public override readonly string ToString() { diff --git a/src/Ocelot/packages.lock.json b/src/Ocelot/packages.lock.json index 5e5abbf97..4cb1d8658 100644 --- a/src/Ocelot/packages.lock.json +++ b/src/Ocelot/packages.lock.json @@ -23,17 +23,6 @@ "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.2" } }, - "Microsoft.AspNetCore.Mvc.NewtonsoftJson": { - "type": "Direct", - "requested": "[8.0.22, )", - "resolved": "8.0.22", - "contentHash": "jSMF5XkqtWvFyvyVJFKrgmGhMh1sDKzIHa+S4WVXa1AY/F0Wou+uFbjO1DPlHt/TWdsWhuhVI1nF0yqIgxRrKQ==", - "dependencies": { - "Microsoft.AspNetCore.JsonPatch": "8.0.22", - "Newtonsoft.Json": "13.0.3", - "Newtonsoft.Json.Bson": "1.0.2" - } - }, "Microsoft.Extensions.DiagnosticAdapter": { "type": "Direct", "requested": "[3.1.32, )", @@ -52,38 +41,21 @@ "StyleCop.Analyzers.Unstable": "1.2.0.556" } }, - "Microsoft.AspNetCore.JsonPatch": { - "type": "Transitive", - "resolved": "8.0.22", - "contentHash": "gquk+JFVSXMJSHP/wWBgF6gYrwk616T6uJPaXvdXxBTRe43KTzuW0M+eMVlJsDH/lHGvItdjv47Y6uJ7WQVoSg==", + "System.Text.Json": { + "type": "Direct", + "requested": "[9.0.12, )", + "resolved": "9.0.12", + "contentHash": "wHv2GrfYd4/uaoZQJj6NOR8M0AlnWJ2/MFAHQomSMqk+/rSIY6AlcitL6LXbTgXf8+ngGjAAmQm17kfbNplQ9w==", "dependencies": { - "Microsoft.CSharp": "4.7.0", - "Newtonsoft.Json": "13.0.3" + "System.IO.Pipelines": "9.0.12", + "System.Text.Encodings.Web": "9.0.12" } }, - "Microsoft.CSharp": { - "type": "Transitive", - "resolved": "4.7.0", - "contentHash": "pTj+D3uJWyN3My70i2Hqo+OXixq3Os2D1nJ2x92FFo6sk8fYS1m1WLNTs0Dc1uPaViH0YvEEwvzddQ7y4rhXmA==" - }, "Microsoft.Extensions.DependencyInjection.Abstractions": { "type": "Transitive", "resolved": "8.0.2", "contentHash": "3iE7UF7MQkCv1cxzCahz+Y/guQbTqieyxyaWKhrRO91itI9cOKO76OHeQDahqG4MmW5umr3CcCvGmK92lWNlbg==" }, - "Newtonsoft.Json": { - "type": "Transitive", - "resolved": "13.0.3", - "contentHash": "HrC5BXdl00IP9zeV+0Z848QWPAoCr9P3bDEZguI+gkLcBKAOxix/tLEAAHC+UvDNPv4a2d18lOReHMOagPa+zQ==" - }, - "Newtonsoft.Json.Bson": { - "type": "Transitive", - "resolved": "1.0.2", - "contentHash": "QYFyxhaABwmq3p/21VrZNYvCg3DaEoN/wUuw5nmfAf0X3HLjgupwhkEWdgfb9nvGAUIv3osmZoD3kKl4jxEmYQ==", - "dependencies": { - "Newtonsoft.Json": "12.0.1" - } - }, "StyleCop.Analyzers.Unstable": { "type": "Transitive", "resolved": "1.2.0.556", @@ -93,10 +65,32 @@ "type": "Transitive", "resolved": "4.7.1", "contentHash": "j81Lovt90PDAq8kLpaJfJKV/rWdWuEk6jfV+MBkee33vzYLEUsy4gXK8laa9V2nZlLM9VM9yA/OOQxxPEJKAMw==" + }, + "System.IO.Pipelines": { + "type": "Transitive", + "resolved": "9.0.12", + "contentHash": "LyvCiOzotNkRgn4wtksKjp/KEljoNtQpuAdunh6PipeyRP/qIdzmeeIjFLUaknkk237eMuYYi2YbkG0pbFBpDg==" + }, + "System.Text.Encodings.Web": { + "type": "Transitive", + "resolved": "9.0.12", + "contentHash": "T69549unMgkU+kbmDOVWYplDiJP6+b1V4NxXh/ao6ITp9xfWCeNPd/H8OI/WLxM/jjYreAVOLJaNayxtFVd7vA==" + } + }, + "net8.0/osx-x64": { + "System.Text.Encodings.Web": { + "type": "Transitive", + "resolved": "9.0.12", + "contentHash": "T69549unMgkU+kbmDOVWYplDiJP6+b1V4NxXh/ao6ITp9xfWCeNPd/H8OI/WLxM/jjYreAVOLJaNayxtFVd7vA==" + } + }, + "net8.0/win-x64": { + "System.Text.Encodings.Web": { + "type": "Transitive", + "resolved": "9.0.12", + "contentHash": "T69549unMgkU+kbmDOVWYplDiJP6+b1V4NxXh/ao6ITp9xfWCeNPd/H8OI/WLxM/jjYreAVOLJaNayxtFVd7vA==" } }, - "net8.0/osx-x64": {}, - "net8.0/win-x64": {}, "net9.0": { "FluentValidation": { "type": "Direct", @@ -119,17 +113,6 @@ "Microsoft.Extensions.DependencyInjection.Abstractions": "9.0.11" } }, - "Microsoft.AspNetCore.Mvc.NewtonsoftJson": { - "type": "Direct", - "requested": "[9.0.11, )", - "resolved": "9.0.11", - "contentHash": "xbpMq5ptjbTivpGz76NQ80Z3Oy204ndTJGoUdQB+vF0DOoii/loz1gr/q2KdFdloAFXju0v4lTiWEhGcIKmtyQ==", - "dependencies": { - "Microsoft.AspNetCore.JsonPatch": "9.0.11", - "Newtonsoft.Json": "13.0.3", - "Newtonsoft.Json.Bson": "1.0.2" - } - }, "Microsoft.Extensions.DiagnosticAdapter": { "type": "Direct", "requested": "[3.1.32, )", @@ -148,38 +131,17 @@ "StyleCop.Analyzers.Unstable": "1.2.0.556" } }, - "Microsoft.AspNetCore.JsonPatch": { - "type": "Transitive", - "resolved": "9.0.11", - "contentHash": "Q+A8LiyaUBurFMSdAzKTpT8jEa9Sc8EsNK0sJEA6glRP4vVl7OGXLV07bfDhcVlFU2hUkn+6Ofmw7HQ0cJ1n1g==", - "dependencies": { - "Microsoft.CSharp": "4.7.0", - "Newtonsoft.Json": "13.0.3" - } - }, - "Microsoft.CSharp": { - "type": "Transitive", - "resolved": "4.7.0", - "contentHash": "pTj+D3uJWyN3My70i2Hqo+OXixq3Os2D1nJ2x92FFo6sk8fYS1m1WLNTs0Dc1uPaViH0YvEEwvzddQ7y4rhXmA==" + "System.Text.Json": { + "type": "Direct", + "requested": "[9.0.12, )", + "resolved": "9.0.12", + "contentHash": "wHv2GrfYd4/uaoZQJj6NOR8M0AlnWJ2/MFAHQomSMqk+/rSIY6AlcitL6LXbTgXf8+ngGjAAmQm17kfbNplQ9w==" }, "Microsoft.Extensions.DependencyInjection.Abstractions": { "type": "Transitive", "resolved": "9.0.11", "contentHash": "+ZxxZzcVU+IEzq12GItUzf/V3mEc5nSLiXijwvDc4zyhbjvSZZ043giSZqGnhakrjwRWjkerIHPrRwm9okEIpw==" }, - "Newtonsoft.Json": { - "type": "Transitive", - "resolved": "13.0.3", - "contentHash": "HrC5BXdl00IP9zeV+0Z848QWPAoCr9P3bDEZguI+gkLcBKAOxix/tLEAAHC+UvDNPv4a2d18lOReHMOagPa+zQ==" - }, - "Newtonsoft.Json.Bson": { - "type": "Transitive", - "resolved": "1.0.2", - "contentHash": "QYFyxhaABwmq3p/21VrZNYvCg3DaEoN/wUuw5nmfAf0X3HLjgupwhkEWdgfb9nvGAUIv3osmZoD3kKl4jxEmYQ==", - "dependencies": { - "Newtonsoft.Json": "12.0.1" - } - }, "StyleCop.Analyzers.Unstable": { "type": "Transitive", "resolved": "1.2.0.556", diff --git a/test/Ocelot.AcceptanceTests/Administration/CacheManagerTests.cs b/test/Ocelot.AcceptanceTests/Administration/CacheManagerTests.cs index 046859959..5d67dfc61 100644 --- a/test/Ocelot.AcceptanceTests/Administration/CacheManagerTests.cs +++ b/test/Ocelot.AcceptanceTests/Administration/CacheManagerTests.cs @@ -2,17 +2,11 @@ using CacheManager.Core; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; -using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; -using Newtonsoft.Json; using Ocelot.AcceptanceTests.Authentication; using Ocelot.Cache.CacheManager; using Ocelot.Configuration.File; using Ocelot.DependencyInjection; -using Ocelot.Middleware; -using System.Net; -using System.Net.Http.Headers; using System.Runtime.CompilerServices; namespace Ocelot.AcceptanceTests.Administration; diff --git a/test/Ocelot.AcceptanceTests/Caching/CachingTests.cs b/test/Ocelot.AcceptanceTests/Caching/CachingTests.cs index b774c90cb..03010537c 100644 --- a/test/Ocelot.AcceptanceTests/Caching/CachingTests.cs +++ b/test/Ocelot.AcceptanceTests/Caching/CachingTests.cs @@ -6,6 +6,7 @@ using Ocelot.Cache.CacheManager; using Ocelot.Configuration.File; using Ocelot.DependencyInjection; +using Ocelot.Infrastructure; using Ocelot.Middleware; using System.Text; using JsonSerializer = System.Text.Json.JsonSerializer; @@ -333,7 +334,7 @@ public static (string TestBody1String, string TestBody2String) TestBodiesFactory LastName = "Test", }; - var testBody1String = JsonSerializer.Serialize(testBody1); + var testBody1String = JsonSerializer.Serialize(testBody1, OcelotSerializerOptions.Web); var testBody2 = new TestBody { @@ -343,7 +344,7 @@ public static (string TestBody1String, string TestBody2String) TestBodiesFactory LastName = "Test", }; - var testBody2String = JsonSerializer.Serialize(testBody2); + var testBody2String = JsonSerializer.Serialize(testBody2, OcelotSerializerOptions.Web); return (testBody1String, testBody2String); } diff --git a/test/Ocelot.AcceptanceTests/Configuration/ConfigurationInConsulTests.cs b/test/Ocelot.AcceptanceTests/Configuration/ConfigurationInConsulTests.cs index fb3d4884b..7f2dd05e0 100644 --- a/test/Ocelot.AcceptanceTests/Configuration/ConfigurationInConsulTests.cs +++ b/test/Ocelot.AcceptanceTests/Configuration/ConfigurationInConsulTests.cs @@ -2,13 +2,14 @@ using Consul; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.DependencyInjection; -using Newtonsoft.Json; using Ocelot.AcceptanceTests.Caching; using Ocelot.Cache.CacheManager; using Ocelot.Configuration.File; using Ocelot.DependencyInjection; +using Ocelot.Infrastructure; using Ocelot.Provider.Consul; using System.Text; +using System.Text.Json; namespace Ocelot.AcceptanceTests.Configuration; @@ -66,7 +67,7 @@ private void GivenThereIsAFakeConsulServiceDiscoveryProvider(int consulPort, str if (context.Request.Method.Equals(HttpMethods.Get, StringComparison.InvariantCultureIgnoreCase) && context.Request.Path.Value == "/v1/kv/InternalConfiguration") { - var json = JsonConvert.SerializeObject(_config); + var json = JsonSerializer.Serialize(_config, OcelotSerializerOptions.Web); var bytes = Encoding.UTF8.GetBytes(json); var base64 = Convert.ToBase64String(bytes); var kvp = new FakeConsulGetResponse(base64); @@ -83,8 +84,8 @@ private void GivenThereIsAFakeConsulServiceDiscoveryProvider(int consulPort, str // Synchronous operations are disallowed. Call ReadAsync or set AllowSynchronousIO to true instead. // var json = reader.ReadToEnd(); var json = await reader.ReadToEndAsync(); - _config = JsonConvert.DeserializeObject(json); - var response = JsonConvert.SerializeObject(true); + _config = JsonSerializer.Deserialize(json, OcelotSerializerOptions.Web); + var response = JsonSerializer.Serialize(true, OcelotSerializerOptions.Web); await context.Response.WriteAsync(response); } catch (Exception e) diff --git a/test/Ocelot.AcceptanceTests/GzipTests.cs b/test/Ocelot.AcceptanceTests/GzipTests.cs index a31bd007a..609b7af78 100644 --- a/test/Ocelot.AcceptanceTests/GzipTests.cs +++ b/test/Ocelot.AcceptanceTests/GzipTests.cs @@ -1,8 +1,8 @@ using Microsoft.AspNetCore.Http; -using Newtonsoft.Json; using System.IO.Compression; using System.Net.Http.Headers; using System.Text; +using System.Text.Json; namespace Ocelot.AcceptanceTests; @@ -30,7 +30,7 @@ public void Should_return_response_200_with_simple_url() private static StreamContent GivenThePostHasGzipContent(object input) { - var json = JsonConvert.SerializeObject(input); + var json = JsonSerializer.Serialize(input); var jsonBytes = Encoding.UTF8.GetBytes(json); var ms = new MemoryStream(); using (var gzip = new GZipStream(ms, CompressionMode.Compress, true)) diff --git a/test/Ocelot.AcceptanceTests/ServiceDiscovery/ConsulConfigurationInConsulTests.cs b/test/Ocelot.AcceptanceTests/ServiceDiscovery/ConsulConfigurationInConsulTests.cs index 76bcd4146..5c5f16fd5 100644 --- a/test/Ocelot.AcceptanceTests/ServiceDiscovery/ConsulConfigurationInConsulTests.cs +++ b/test/Ocelot.AcceptanceTests/ServiceDiscovery/ConsulConfigurationInConsulTests.cs @@ -1,13 +1,14 @@ using Consul; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.DependencyInjection; -using Newtonsoft.Json; using Ocelot.AcceptanceTests.RateLimiting; using Ocelot.Cache; using Ocelot.Configuration.File; using Ocelot.DependencyInjection; +using Ocelot.Infrastructure; using Ocelot.Provider.Consul; using System.Text; +using System.Text.Json; namespace Ocelot.AcceptanceTests.ServiceDiscovery; @@ -348,11 +349,11 @@ private void GivenThereIsAFakeConsulServiceDiscoveryProvider(int port, string se { if (context.Request.Method.Equals(HttpMethods.Get, StringComparison.CurrentCultureIgnoreCase) && context.Request.Path.Value == "/v1/kv/InternalConfiguration") { - var json = JsonConvert.SerializeObject(_config); + var json = JsonSerializer.Serialize(_config, OcelotSerializerOptions.Web); var bytes = Encoding.UTF8.GetBytes(json); var base64 = Convert.ToBase64String(bytes); var kvp = new FakeConsulGetResponse(base64); - json = JsonConvert.SerializeObject(new[] { kvp }); + json = JsonSerializer.Serialize(new[] { kvp }, OcelotSerializerOptions.Web); context.Response.Headers.Append("Content-Type", "application/json"); await context.Response.WriteAsync(json); } @@ -365,8 +366,8 @@ private void GivenThereIsAFakeConsulServiceDiscoveryProvider(int port, string se // Synchronous operations are disallowed. Call ReadAsync or set AllowSynchronousIO to true instead. // var json = reader.ReadToEnd(); var json = await reader.ReadToEndAsync(); - _config = JsonConvert.DeserializeObject(json); - var response = JsonConvert.SerializeObject(true); + _config = JsonSerializer.Deserialize(json, OcelotSerializerOptions.Web); + var response = JsonSerializer.Serialize(true, OcelotSerializerOptions.Web); await context.Response.WriteAsync(response); } catch (Exception e) @@ -377,7 +378,7 @@ private void GivenThereIsAFakeConsulServiceDiscoveryProvider(int port, string se } else if (context.Request.Path.Value == $"/v1/health/service/{serviceName}") { - var json = JsonConvert.SerializeObject(_consulServices); + var json = JsonSerializer.Serialize(_consulServices, OcelotSerializerOptions.Web); context.Response.Headers.Append("Content-Type", "application/json"); await context.Response.WriteAsync(json); } diff --git a/test/Ocelot.AcceptanceTests/ServiceDiscovery/ConsulServiceDiscoveryTests.cs b/test/Ocelot.AcceptanceTests/ServiceDiscovery/ConsulServiceDiscoveryTests.cs index 56794b069..32e1a934f 100644 --- a/test/Ocelot.AcceptanceTests/ServiceDiscovery/ConsulServiceDiscoveryTests.cs +++ b/test/Ocelot.AcceptanceTests/ServiceDiscovery/ConsulServiceDiscoveryTests.cs @@ -2,7 +2,6 @@ using Microsoft.AspNetCore.Http; using Microsoft.Extensions.DependencyInjection; using Microsoft.Net.Http.Headers; -using Newtonsoft.Json; using Ocelot.AcceptanceTests.LoadBalancer; using Ocelot.Configuration; using Ocelot.Configuration.File; @@ -16,6 +15,7 @@ using Ocelot.Provider.Consul.Interfaces; using Ocelot.ServiceDiscovery.Providers; using System.Runtime.CompilerServices; +using System.Text.Json; using System.Text.RegularExpressions; namespace Ocelot.AcceptanceTests.ServiceDiscovery; @@ -669,7 +669,8 @@ private void GivenThereIsAFakeConsulServiceDiscoveryProvider(string url) // Use the parsed service name to filter the registered Consul services var serviceName = pathMatch.Groups["serviceName"].Value; var services = _consulServices.Where(x => x.Service.Service == serviceName).ToList(); - var json = JsonConvert.SerializeObject(services); + var json = JsonSerializer.Serialize(services, OcelotSerializerOptions.Web); + json = json.Replace("\"Name\":", "\"Node\":"); //} context.Response.Headers.Append("Content-Type", "application/json"); @@ -681,7 +682,7 @@ private void GivenThereIsAFakeConsulServiceDiscoveryProvider(string url) { //_counterNodes++; int count = Interlocked.Increment(ref _counterNodes); - var json = JsonConvert.SerializeObject(_consulNodes); + var json = JsonSerializer.Serialize(_consulNodes, OcelotSerializerOptions.Web); context.Response.Headers.Append("Content-Type", "application/json"); await context.Response.WriteAsync(json); } diff --git a/test/Ocelot.AcceptanceTests/ServiceDiscovery/ConsulTwoDownstreamServicesTests.cs b/test/Ocelot.AcceptanceTests/ServiceDiscovery/ConsulTwoDownstreamServicesTests.cs index aa5ca787d..4e353d2aa 100644 --- a/test/Ocelot.AcceptanceTests/ServiceDiscovery/ConsulTwoDownstreamServicesTests.cs +++ b/test/Ocelot.AcceptanceTests/ServiceDiscovery/ConsulTwoDownstreamServicesTests.cs @@ -1,6 +1,6 @@ using Consul; using Microsoft.AspNetCore.Http; -using Newtonsoft.Json; +using System.Text.Json; namespace Ocelot.AcceptanceTests.ServiceDiscovery; @@ -49,7 +49,7 @@ private void GivenThereIsAFakeConsulServiceDiscoveryProvider(int port) { if (context.Request.Path.Value == "/v1/health/service/product") { - var json = JsonConvert.SerializeObject(_serviceEntries); + var json = JsonSerializer.Serialize(_serviceEntries); context.Response.Headers.Append("Content-Type", "application/json"); return context.Response.WriteAsync(json); } diff --git a/test/Ocelot.AcceptanceTests/ServiceDiscovery/ConsulWebSocketTests.cs b/test/Ocelot.AcceptanceTests/ServiceDiscovery/ConsulWebSocketTests.cs index 6ff49df14..7678c2796 100644 --- a/test/Ocelot.AcceptanceTests/ServiceDiscovery/ConsulWebSocketTests.cs +++ b/test/Ocelot.AcceptanceTests/ServiceDiscovery/ConsulWebSocketTests.cs @@ -1,12 +1,13 @@ using Consul; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.DependencyInjection; -using Newtonsoft.Json; using Ocelot.AcceptanceTests.WebSockets; using Ocelot.Configuration.File; using Ocelot.DependencyInjection; +using Ocelot.Infrastructure; using Ocelot.Provider.Consul; using System.Text; +using System.Text.Json; namespace Ocelot.AcceptanceTests.ServiceDiscovery; @@ -100,7 +101,7 @@ Task MapServicePath(HttpContext context) { if (context.Request.Path.Value == $"/v1/health/service/{serviceName}") { - var json = JsonConvert.SerializeObject(_serviceEntries); + var json = JsonSerializer.Serialize(_serviceEntries, OcelotSerializerOptions.Web); context.Response.Headers.Append("Content-Type", "application/json"); return context.Response.WriteAsync(json); } diff --git a/test/Ocelot.AcceptanceTests/ServiceDiscovery/EurekaServiceDiscoveryTests.cs b/test/Ocelot.AcceptanceTests/ServiceDiscovery/EurekaServiceDiscoveryTests.cs index 64df78b2c..4aee02e7c 100644 --- a/test/Ocelot.AcceptanceTests/ServiceDiscovery/EurekaServiceDiscoveryTests.cs +++ b/test/Ocelot.AcceptanceTests/ServiceDiscovery/EurekaServiceDiscoveryTests.cs @@ -1,11 +1,13 @@ using Microsoft.AspNetCore.Http; -using Newtonsoft.Json; using Ocelot.Configuration.File; using Ocelot.DependencyInjection; +using Ocelot.Infrastructure; using Ocelot.LoadBalancer.Balancers; using Ocelot.Provider.Eureka; using Steeltoe.Common.Discovery; using System.Runtime.CompilerServices; +using System.Text.Json; +using System.Text.Json.Serialization; namespace Ocelot.AcceptanceTests.ServiceDiscovery; @@ -139,7 +141,7 @@ Task MapEurekaService(HttpContext context) versions__delta = "1", }, }; - var json = JsonConvert.SerializeObject(applications); + var json = JsonSerializer.Serialize(applications, OcelotSerializerOptions.Web); context.Response.Headers.Append("Content-Type", "application/json"); return context.Response.WriteAsync(json); } @@ -188,23 +190,23 @@ public FakeEurekaService(string serviceId, string host, int port, bool isSecure, #pragma warning disable IDE1006 // Naming Styles public class Port { - [JsonProperty("$")] + [JsonPropertyName("$")] public int value { get; set; } - [JsonProperty("@enabled")] + [JsonPropertyName("@enabled")] public string enabled { get; set; } } public class SecurePort { - [JsonProperty("$")] + [JsonPropertyName("$")] public int value { get; set; } - [JsonProperty("@enabled")] + [JsonPropertyName("@enabled")] public string enabled { get; set; } } public class DataCenterInfo { - [JsonProperty("@class")] + [JsonPropertyName("@class")] public string value { get; set; } public string name { get; set; } } @@ -219,7 +221,7 @@ public class LeaseInfo } public class ValueMetadata { - [JsonProperty("@class")] + [JsonPropertyName("@class")] public string value { get; set; } } public class Instance diff --git a/test/Ocelot.AcceptanceTests/ServiceDiscovery/KubernetesServiceDiscoveryTests.cs b/test/Ocelot.AcceptanceTests/ServiceDiscovery/KubernetesServiceDiscoveryTests.cs index ec6a5108e..d899df01e 100644 --- a/test/Ocelot.AcceptanceTests/ServiceDiscovery/KubernetesServiceDiscoveryTests.cs +++ b/test/Ocelot.AcceptanceTests/ServiceDiscovery/KubernetesServiceDiscoveryTests.cs @@ -4,11 +4,11 @@ using Microsoft.AspNetCore.Http; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; -using Newtonsoft.Json; using Ocelot.AcceptanceTests.LoadBalancer; using Ocelot.Configuration; using Ocelot.Configuration.File; using Ocelot.DependencyInjection; +using Ocelot.Infrastructure; using Ocelot.Infrastructure.Extensions; using Ocelot.LoadBalancer.Balancers; using Ocelot.Logging; @@ -18,6 +18,7 @@ using Ocelot.Values; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; +using System.Text.Json; namespace Ocelot.AcceptanceTests.ServiceDiscovery; @@ -442,7 +443,7 @@ private void GivenThereIsAFakeKubernetesProvider(EndpointsV1 endpoints, bool isS } endpoints.Metadata.Generation = _k8sServiceGeneration; - json = JsonConvert.SerializeObject(endpoints, KubeResourceClient.SerializerSettings); + json = JsonSerializer.Serialize(endpoints, OcelotSerializerOptions.Web); } if (context.Request.Headers.TryGetValue("Authorization", out var values)) @@ -494,7 +495,8 @@ private async Task GivenHandleWatchRequest(HttpContext context, foreach (var @event in events) { _k8sWatchResetEvent.WaitOne(); - var json = JsonConvert.SerializeObject(@event, KubeResourceClient.SerializerSettings); + // var json = JsonSerializer.Serialize(@event, OcelotSerializerOptions.Web); // KubeResourceClient.SerializerSettings); + var json = Newtonsoft.Json.JsonConvert.SerializeObject(@event, KubeResourceClient.SerializerSettings); await using var sw = new StreamWriter(context.Response.Body); await sw.WriteLineAsync(json); await sw.FlushAsync(); diff --git a/test/Ocelot.AcceptanceTests/Steps.cs b/test/Ocelot.AcceptanceTests/Steps.cs index a8af40c4a..02258c314 100644 --- a/test/Ocelot.AcceptanceTests/Steps.cs +++ b/test/Ocelot.AcceptanceTests/Steps.cs @@ -3,20 +3,22 @@ using Microsoft.AspNetCore.TestHost; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; -using Ocelot.AcceptanceTests.Properties; +using Ocelot.AcceptanceTests.Properties; using Ocelot.Configuration.File; using Ocelot.DependencyInjection; using Ocelot.Middleware; using System.Runtime.CompilerServices; +using System.Text; +using System.Text.Json; namespace Ocelot.AcceptanceTests; public class Steps : AcceptanceSteps { - public Steps() : base() + public Steps() : base() { BddfyConfig.Configure(); - } + } public static bool IsCiCd() => IsRunningInGitHubActions(); public static bool IsRunningInGitHubActions() => Environment.GetEnvironmentVariable("GITHUB_ACTIONS") == "true"; @@ -36,57 +38,57 @@ public void GivenOcelotIsRunning(OcelotPipelineConfiguration pipelineConfig) ocelotServer = new TestServer(builder); ocelotClient = ocelotServer.CreateClient(); } - + protected virtual void GivenThereIsAServiceRunningOn(int port, [CallerMemberName] string responseBody = "") => GivenThereIsAServiceRunningOn(port, HttpStatusCode.OK, responseBody); - + protected virtual HttpStatusCode MapStatus_StatusCode { get; set; } = HttpStatusCode.OK; protected virtual Func MapStatus_ResponseBody { get; set; } protected virtual Task MapStatus(HttpContext context) - { + { context.Response.StatusCode = (int)MapStatus_StatusCode; return context.Response.WriteAsync(MapStatus_ResponseBody?.Invoke() ?? string.Empty); - } + } protected virtual void GivenThereIsAServiceRunningOn(int port, HttpStatusCode statusCode, [CallerMemberName] string responseBody = "") - { + { MapStatus_StatusCode = statusCode; MapStatus_ResponseBody = () => responseBody; handler.GivenThereIsAServiceRunningOn(port, MapStatus); } - + protected Func pMapOK_ResponseBody; protected virtual Task MapOK(HttpContext context) - { + { context.Response.StatusCode = StatusCodes.Status200OK; return context.Response.WriteAsync(pMapOK_ResponseBody?.Invoke() ?? string.Empty); - } + } public virtual void GivenThereIsAServiceRunningOnPath(int port, string basePath, [CallerMemberName] string responseBody = "") - { + { pMapOK_ResponseBody = () => responseBody; handler.GivenThereIsAServiceRunningOn(port, basePath, MapOK); - } + } public virtual void GivenThereIsAServiceRunningOn(int port, string basePath, RequestDelegate requestDelegate) - { + { handler.GivenThereIsAServiceRunningOn(port, basePath, requestDelegate); - } - + } + protected override FileHostAndPort Localhost(int port) => base.Localhost(port) as FileHostAndPort; protected override FileConfiguration GivenConfiguration(params object[] routes) => base.GivenConfiguration(routes) as FileConfiguration; protected override FileRoute GivenDefaultRoute(int port) => base.GivenDefaultRoute(port) as FileRoute; protected override FileRoute GivenCatchAllRoute(int port) => base.GivenCatchAllRoute(port) as FileRoute; protected override FileRoute GivenRoute(int port, string upstream = null, string downstream = null) => base.GivenRoute(port, upstream, downstream) as FileRoute; - + protected static FileRouteBox Box(FileRoute route) => new(route); - + #region TODO: Move to Ocelot.Testing package public virtual string Body([CallerMemberName] string responseBody = null) => responseBody ?? GetType().Name; public virtual string TestName([CallerMemberName] string testName = null) => testName ?? GetType().Name; public static Task GivenIWaitAsync(int wait) => Task.Delay(wait); public Task ThenTheResponseShouldBeAsync(HttpStatusCode expected, [CallerMemberName] string expectedBody = null) - { + { ThenTheStatusCodeShouldBe(expected); return ThenTheResponseBodyShouldBeAsync(expectedBody ?? Body(expectedBody)); - } + } public Task ThenTheResponseBodyShouldBeEmpty() => ThenTheResponseBodyShouldBeAsync(string.Empty); public Task GivenOcelotIsRunningAsync(Action configureServices) => Task.Run(() => GivenOcelotIsRunning(configureServices)); // TODO Need async version in the lib diff --git a/test/Ocelot.AcceptanceTests/packages.lock.json b/test/Ocelot.AcceptanceTests/packages.lock.json index 4d47b9b1b..12d3d06b2 100644 --- a/test/Ocelot.AcceptanceTests/packages.lock.json +++ b/test/Ocelot.AcceptanceTests/packages.lock.json @@ -1572,8 +1572,8 @@ }, "System.IO.Pipelines": { "type": "Transitive", - "resolved": "9.0.11", - "contentHash": "NfGnevAV0r2gqtZWxa/7uCm3MNRYz1o4WRHhFahgBq46LuG2eaLwXIlPgtgaRUvf9CCrGFnuzN47MOzJUH1HKg==" + "resolved": "9.0.12", + "contentHash": "LyvCiOzotNkRgn4wtksKjp/KEljoNtQpuAdunh6PipeyRP/qIdzmeeIjFLUaknkk237eMuYYi2YbkG0pbFBpDg==" }, "System.Linq": { "type": "Transitive", @@ -2063,16 +2063,16 @@ }, "System.Text.Encodings.Web": { "type": "Transitive", - "resolved": "9.0.11", - "contentHash": "l5L3Ov+pyD0dfK2bv6IMU2KPEyaaWnix6U0/YhgkNBGEOAgVTVlvh5ZyXWuuRlCtLnOziz+VtM5HFeqLlH2AbA==" + "resolved": "9.0.12", + "contentHash": "T69549unMgkU+kbmDOVWYplDiJP6+b1V4NxXh/ao6ITp9xfWCeNPd/H8OI/WLxM/jjYreAVOLJaNayxtFVd7vA==" }, "System.Text.Json": { "type": "Transitive", - "resolved": "9.0.11", - "contentHash": "DGToqSFbBSU6pMSbZuJ+7jDvLa73rvpcYdGFqZIB3FKdCVlEAbrBJrl9PuCT6E0QbdhXjPwqalYc5lxjUqMQzw==", + "resolved": "9.0.12", + "contentHash": "wHv2GrfYd4/uaoZQJj6NOR8M0AlnWJ2/MFAHQomSMqk+/rSIY6AlcitL6LXbTgXf8+ngGjAAmQm17kfbNplQ9w==", "dependencies": { - "System.IO.Pipelines": "9.0.11", - "System.Text.Encodings.Web": "9.0.11" + "System.IO.Pipelines": "9.0.12", + "System.Text.Encodings.Web": "9.0.12" } }, "System.Text.RegularExpressions": { @@ -2254,8 +2254,8 @@ "FluentValidation": "[12.1.1, )", "IPAddressRange": "[6.3.0, )", "Microsoft.AspNetCore.MiddlewareAnalysis": "[8.0.22, )", - "Microsoft.AspNetCore.Mvc.NewtonsoftJson": "[8.0.22, )", - "Microsoft.Extensions.DiagnosticAdapter": "[3.1.32, )" + "Microsoft.Extensions.DiagnosticAdapter": "[3.1.32, )", + "System.Text.Json": "[9.0.12, )" } }, "ocelot.cache.cachemanager": { @@ -3215,8 +3215,8 @@ }, "System.Text.Encodings.Web": { "type": "Transitive", - "resolved": "9.0.11", - "contentHash": "l5L3Ov+pyD0dfK2bv6IMU2KPEyaaWnix6U0/YhgkNBGEOAgVTVlvh5ZyXWuuRlCtLnOziz+VtM5HFeqLlH2AbA==" + "resolved": "9.0.12", + "contentHash": "T69549unMgkU+kbmDOVWYplDiJP6+b1V4NxXh/ao6ITp9xfWCeNPd/H8OI/WLxM/jjYreAVOLJaNayxtFVd7vA==" }, "System.Threading.Tasks": { "type": "Transitive", @@ -4137,8 +4137,8 @@ }, "System.Text.Encodings.Web": { "type": "Transitive", - "resolved": "9.0.11", - "contentHash": "l5L3Ov+pyD0dfK2bv6IMU2KPEyaaWnix6U0/YhgkNBGEOAgVTVlvh5ZyXWuuRlCtLnOziz+VtM5HFeqLlH2AbA==" + "resolved": "9.0.12", + "contentHash": "T69549unMgkU+kbmDOVWYplDiJP6+b1V4NxXh/ao6ITp9xfWCeNPd/H8OI/WLxM/jjYreAVOLJaNayxtFVd7vA==" }, "System.Threading.Overlapped": { "type": "Transitive", @@ -6232,8 +6232,8 @@ }, "System.Text.Json": { "type": "Transitive", - "resolved": "9.0.11", - "contentHash": "DGToqSFbBSU6pMSbZuJ+7jDvLa73rvpcYdGFqZIB3FKdCVlEAbrBJrl9PuCT6E0QbdhXjPwqalYc5lxjUqMQzw==" + "resolved": "9.0.12", + "contentHash": "wHv2GrfYd4/uaoZQJj6NOR8M0AlnWJ2/MFAHQomSMqk+/rSIY6AlcitL6LXbTgXf8+ngGjAAmQm17kfbNplQ9w==" }, "System.Text.RegularExpressions": { "type": "Transitive", @@ -6414,8 +6414,8 @@ "FluentValidation": "[12.1.1, )", "IPAddressRange": "[6.3.0, )", "Microsoft.AspNetCore.MiddlewareAnalysis": "[9.0.11, )", - "Microsoft.AspNetCore.Mvc.NewtonsoftJson": "[9.0.11, )", - "Microsoft.Extensions.DiagnosticAdapter": "[3.1.32, )" + "Microsoft.Extensions.DiagnosticAdapter": "[3.1.32, )", + "System.Text.Json": "[9.0.12, )" } }, "ocelot.cache.cachemanager": { diff --git a/test/Ocelot.Benchmarks/AllTheThingsBenchmarks.cs b/test/Ocelot.Benchmarks/AllTheThingsBenchmarks.cs index b154a6929..fa8674457 100644 --- a/test/Ocelot.Benchmarks/AllTheThingsBenchmarks.cs +++ b/test/Ocelot.Benchmarks/AllTheThingsBenchmarks.cs @@ -3,10 +3,11 @@ using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; -using Newtonsoft.Json; using Ocelot.Configuration.File; using Ocelot.DependencyInjection; -using Ocelot.Middleware; +using Ocelot.Infrastructure; +using Ocelot.Middleware; +using System.Text.Json; namespace Ocelot.Benchmarks; @@ -112,7 +113,7 @@ public static void GivenThereIsAConfiguration(FileConfiguration fileConfiguratio { var configurationPath = Path.Combine(AppContext.BaseDirectory, "ocelot.json"); - var jsonConfiguration = JsonConvert.SerializeObject(fileConfiguration); + var jsonConfiguration = JsonSerializer.Serialize(fileConfiguration, OcelotSerializerOptions.Web); if (File.Exists(configurationPath)) { diff --git a/test/Ocelot.Benchmarks/JsonSerializerBenchmark.cs b/test/Ocelot.Benchmarks/JsonSerializerBenchmark.cs new file mode 100644 index 000000000..37c6f3036 --- /dev/null +++ b/test/Ocelot.Benchmarks/JsonSerializerBenchmark.cs @@ -0,0 +1,87 @@ +using BenchmarkDotNet.Jobs; +using Bogus; +using Newtonsoft.Json; +using JsonSerializer = System.Text.Json.JsonSerializer; + +namespace Ocelot.Benchmarks; + +[SimpleJob(RuntimeMoniker.Net80)] +[Config(typeof(JsonSerializerBenchmark))] +public class JsonSerializerBenchmark : ManualConfig +{ + private string _serializedTestUsers; + + private List _testUsers = new(); + + [Params(1000)] + public int Count { get; set; } + + [GlobalSetup] + public void GlobalSetup() + { + Faker faker = new Faker().CustomInstantiator(f => new User + { + UserId = Guid.NewGuid(), + FirstName = f.Name.FirstName(), + LastName = f.Name.LastName(), + FullName = f.Name.FullName(), + Username = f.Internet.UserName(f.Name.FirstName(), f.Name.LastName()), + Email = f.Internet.Email(f.Name.FirstName(), f.Name.LastName()), + }); + _testUsers = faker.Generate(Count); + _serializedTestUsers = JsonSerializer.Serialize(_testUsers); + } + + [Benchmark] + [BenchmarkCategory("Serialize", "Newtonsoft")] + public void NewtonsoftSerializeBigData() + { + _ = JsonConvert.SerializeObject(_testUsers); + } + + [Benchmark] + [BenchmarkCategory("Serialize", "Microsoft")] + public void MicrosoftSerializeBigData() + { + _ = JsonSerializer.Serialize(_testUsers); + } + + [Benchmark] + [BenchmarkCategory("Deserialize", "Newtonsoft")] + public void NewtonsoftDeserializeBigData() + { + _ = JsonConvert.DeserializeObject>(_serializedTestUsers); + } + + [Benchmark] + [BenchmarkCategory("Deserialize", "Microsoft")] + public void MicrosoftDeserializeBigData() + { + _ = JsonSerializer.Deserialize>(_serializedTestUsers); + } +} + +//BenchmarkDotNet v0.13.11, Windows 11 (10.0.22631.3880/23H2/2023Update/SunValley3) +//Intel Core i7-10870H CPU 2.20GHz, 1 CPU, 16 logical and 8 physical cores +// .NET SDK 8.0.303 +// [Host] : .NET 6.0.32 (6.0.3224.31407), X64 RyuJIT AVX2[AttachedDebugger] +// .NET 8.0 : .NET 8.0.7 (8.0.724.31311), X64 RyuJIT AVX2 + +// Job =.NET 8.0 Runtime=.NET 8.0 + +// | Method | Count | Mean | Error | StdDev | Median | Op/s | Gen0 | Gen1 | Gen2 | Allocated | +// |----------------------------- |------ |-----------:|---------:|----------:|-----------:|--------:|---------:|---------:|---------:|----------:| +// | MicrosoftDeserializeBigData | 1000 | 856.3 us | 53.98 us | 157.47 us | 797.1 us | 1,167.8 | 39.0625 | 13.6719 | - | 328.78 KB | +// | NewtonsoftDeserializeBigData | 1000 | 1,137.2 us | 18.74 us | 17.53 us | 1,132.8 us | 879.4 | 54.6875 | 17.5781 | - | 457.94 KB | +// |==============================================================================================================================================| +// | MicrosoftSerializeBigData | 1000 | 646.4 us | 12.72 us | 20.90 us | 645.7 us | 1,546.9 | 110.3516 | 110.3516 | 110.3516 | 350.02 KB | +// | NewtonsoftSerializeBigData | 1000 | 1,033.4 us | 19.37 us | 42.53 us | 1,022.8 us | 967.7 | 109.3750 | 109.3750 | 109.3750 | 837.82 KB | +public class User +{ + public Guid UserId { get; set; } + public string FirstName { get; set; } + public string LastName { get; set; } + public string FullName { get; set; } + public string Username { get; set; } + public string Email { get; set; } +} diff --git a/test/Ocelot.Benchmarks/MsLoggerBenchmarks.cs b/test/Ocelot.Benchmarks/MsLoggerBenchmarks.cs index 242eaed20..77af491bd 100644 --- a/test/Ocelot.Benchmarks/MsLoggerBenchmarks.cs +++ b/test/Ocelot.Benchmarks/MsLoggerBenchmarks.cs @@ -5,11 +5,12 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; -using Newtonsoft.Json; using Ocelot.Configuration.File; using Ocelot.DependencyInjection; +using Ocelot.Infrastructure; using Ocelot.Logging; using Ocelot.Middleware; +using System.Text.Json; namespace Ocelot.Benchmarks; @@ -162,7 +163,7 @@ public static void GivenThereIsAConfiguration(FileConfiguration fileConfiguratio { var configurationPath = Path.Combine(AppContext.BaseDirectory, "ocelot.json"); - var jsonConfiguration = JsonConvert.SerializeObject(fileConfiguration); + var jsonConfiguration = JsonSerializer.Serialize(fileConfiguration, OcelotSerializerOptions.Web); if (File.Exists(configurationPath)) { diff --git a/test/Ocelot.Benchmarks/Ocelot.Benchmarks.csproj b/test/Ocelot.Benchmarks/Ocelot.Benchmarks.csproj index 20cb2a917..026888f5e 100644 --- a/test/Ocelot.Benchmarks/Ocelot.Benchmarks.csproj +++ b/test/Ocelot.Benchmarks/Ocelot.Benchmarks.csproj @@ -23,11 +23,13 @@ + all + diff --git a/test/Ocelot.Benchmarks/PayloadBenchmarks.cs b/test/Ocelot.Benchmarks/PayloadBenchmarks.cs index a1c58bc16..1b553e6af 100644 --- a/test/Ocelot.Benchmarks/PayloadBenchmarks.cs +++ b/test/Ocelot.Benchmarks/PayloadBenchmarks.cs @@ -4,14 +4,15 @@ using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; -using Newtonsoft.Json; using Ocelot.Configuration.File; using Ocelot.DependencyInjection; +using Ocelot.Infrastructure; using Ocelot.Middleware; using System.Diagnostics; using System.Net.Http.Headers; using System.Reflection; using System.Text; +using System.Text.Json; namespace Ocelot.Benchmarks; @@ -112,7 +113,7 @@ private static string GetBaseDirectory() private static object[] GeneratePayload(int size, string directory, string fileName, bool isJson) { var filePath = Path.Combine(directory, fileName); - var generateDummy = isJson ? (Func) GenerateDummyJsonFile : GenerateDummyDatFile; + var generateDummy = isJson ? (Func)GenerateDummyJsonFile : GenerateDummyDatFile; return new object[] { generateDummy(size, filePath), @@ -220,7 +221,7 @@ private void GivenOcelotIsRunning(string url) public static void GivenThereIsAConfiguration(FileConfiguration fileConfiguration) { var configurationPath = Path.Combine(AppContext.BaseDirectory, ConfigurationBuilderExtensions.PrimaryConfigFile); - var jsonConfiguration = JsonConvert.SerializeObject(fileConfiguration); + var jsonConfiguration = JsonSerializer.Serialize(fileConfiguration, OcelotSerializerOptions.Web); if (File.Exists(configurationPath)) { diff --git a/test/Ocelot.Benchmarks/Program.cs b/test/Ocelot.Benchmarks/Program.cs index bea66ff17..689d1fea6 100644 --- a/test/Ocelot.Benchmarks/Program.cs +++ b/test/Ocelot.Benchmarks/Program.cs @@ -17,7 +17,15 @@ public static void Main(string[] args) typeof(MsLoggerBenchmarks), typeof(PayloadBenchmarks), typeof(ResponseBenchmarks), + typeof(JsonSerializerBenchmark), }); - switcher.Run(args); + + var config = ManualConfig.Create(DefaultConfig.Instance) + .AddAnalyser(BenchmarkDotNet.Analysers.EnvironmentAnalyser.Default) + .AddExporter(BenchmarkDotNet.Exporters.MarkdownExporter.GitHub) + .AddDiagnoser(BenchmarkDotNet.Diagnosers.MemoryDiagnoser.Default) + .AddColumn(StatisticColumn.OperationsPerSecond); + + switcher.Run(args, config); } } diff --git a/test/Ocelot.Benchmarks/ResponseBenchmarks.cs b/test/Ocelot.Benchmarks/ResponseBenchmarks.cs index cf8d0777d..8f43f2214 100644 --- a/test/Ocelot.Benchmarks/ResponseBenchmarks.cs +++ b/test/Ocelot.Benchmarks/ResponseBenchmarks.cs @@ -4,15 +4,15 @@ using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; -using Newtonsoft.Json; using Ocelot.Configuration.File; using Ocelot.DependencyInjection; +using Ocelot.Infrastructure; using Ocelot.Middleware; using System.Diagnostics; using System.Net.Http.Headers; using System.Reflection; using System.Text; -using Ocelot.Responses; +using System.Text.Json; namespace Ocelot.Benchmarks; @@ -222,7 +222,7 @@ private void GivenOcelotIsRunning(string url) public static void GivenThereIsAConfiguration(FileConfiguration fileConfiguration) { var configurationPath = Path.Combine(AppContext.BaseDirectory, ConfigurationBuilderExtensions.PrimaryConfigFile); - var jsonConfiguration = JsonConvert.SerializeObject(fileConfiguration); + var jsonConfiguration = JsonSerializer.Serialize(fileConfiguration, OcelotSerializerOptions.Web); if (File.Exists(configurationPath)) { diff --git a/test/Ocelot.Benchmarks/SerilogBenchmarks.cs b/test/Ocelot.Benchmarks/SerilogBenchmarks.cs index 1c9d89a1c..bea044453 100644 --- a/test/Ocelot.Benchmarks/SerilogBenchmarks.cs +++ b/test/Ocelot.Benchmarks/SerilogBenchmarks.cs @@ -5,13 +5,14 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; -using Newtonsoft.Json; using Ocelot.Configuration.File; using Ocelot.DependencyInjection; +using Ocelot.Infrastructure; using Ocelot.Logging; using Ocelot.Middleware; using Serilog; using Serilog.Core; +using System.Text.Json; namespace Ocelot.Benchmarks; @@ -193,7 +194,7 @@ public static void GivenThereIsAConfiguration(FileConfiguration fileConfiguratio { var configurationPath = Path.Combine(AppContext.BaseDirectory, "ocelot.json"); - var jsonConfiguration = JsonConvert.SerializeObject(fileConfiguration); + var jsonConfiguration = JsonSerializer.Serialize(fileConfiguration, OcelotSerializerOptions.Web); if (File.Exists(configurationPath)) { diff --git a/test/Ocelot.Benchmarks/packages.lock.json b/test/Ocelot.Benchmarks/packages.lock.json index 55bcb3db3..56d5e8295 100644 --- a/test/Ocelot.Benchmarks/packages.lock.json +++ b/test/Ocelot.Benchmarks/packages.lock.json @@ -20,6 +20,12 @@ "System.Management": "9.0.5" } }, + "Bogus": { + "type": "Direct", + "requested": "[35.5.1, )", + "resolved": "35.5.1", + "contentHash": "GBp2peww04szEJ0GlBlzCYilFDaSkL7Ja4m37YeTRjC/mgoiZnUuifmgUxVD/oLU2MC1uoXfQYK91doGp7Zkpg==" + }, "Ocelot.Testing": { "type": "Direct", "requested": "[24.1.0-beta.1, )", @@ -56,6 +62,16 @@ "StyleCop.Analyzers.Unstable": "1.2.0.556" } }, + "System.Text.Json": { + "type": "Direct", + "requested": "[9.0.12, )", + "resolved": "9.0.12", + "contentHash": "wHv2GrfYd4/uaoZQJj6NOR8M0AlnWJ2/MFAHQomSMqk+/rSIY6AlcitL6LXbTgXf8+ngGjAAmQm17kfbNplQ9w==", + "dependencies": { + "System.IO.Pipelines": "9.0.12", + "System.Text.Encodings.Web": "9.0.12" + } + }, "BenchmarkDotNet.Annotations": { "type": "Transitive", "resolved": "0.15.8", @@ -449,8 +465,8 @@ }, "System.IO.Pipelines": { "type": "Transitive", - "resolved": "9.0.11", - "contentHash": "NfGnevAV0r2gqtZWxa/7uCm3MNRYz1o4WRHhFahgBq46LuG2eaLwXIlPgtgaRUvf9CCrGFnuzN47MOzJUH1HKg==" + "resolved": "9.0.12", + "contentHash": "LyvCiOzotNkRgn4wtksKjp/KEljoNtQpuAdunh6PipeyRP/qIdzmeeIjFLUaknkk237eMuYYi2YbkG0pbFBpDg==" }, "System.Management": { "type": "Transitive", @@ -494,17 +510,8 @@ }, "System.Text.Encodings.Web": { "type": "Transitive", - "resolved": "9.0.11", - "contentHash": "l5L3Ov+pyD0dfK2bv6IMU2KPEyaaWnix6U0/YhgkNBGEOAgVTVlvh5ZyXWuuRlCtLnOziz+VtM5HFeqLlH2AbA==" - }, - "System.Text.Json": { - "type": "Transitive", - "resolved": "9.0.11", - "contentHash": "DGToqSFbBSU6pMSbZuJ+7jDvLa73rvpcYdGFqZIB3FKdCVlEAbrBJrl9PuCT6E0QbdhXjPwqalYc5lxjUqMQzw==", - "dependencies": { - "System.IO.Pipelines": "9.0.11", - "System.Text.Encodings.Web": "9.0.11" - } + "resolved": "9.0.12", + "contentHash": "T69549unMgkU+kbmDOVWYplDiJP6+b1V4NxXh/ao6ITp9xfWCeNPd/H8OI/WLxM/jjYreAVOLJaNayxtFVd7vA==" }, "ocelot": { "type": "Project", @@ -512,8 +519,8 @@ "FluentValidation": "[12.1.1, )", "IPAddressRange": "[6.3.0, )", "Microsoft.AspNetCore.MiddlewareAnalysis": "[8.0.22, )", - "Microsoft.AspNetCore.Mvc.NewtonsoftJson": "[8.0.22, )", - "Microsoft.Extensions.DiagnosticAdapter": "[3.1.32, )" + "Microsoft.Extensions.DiagnosticAdapter": "[3.1.32, )", + "System.Text.Json": "[9.0.12, )" } } }, @@ -556,8 +563,8 @@ }, "System.Text.Encodings.Web": { "type": "Transitive", - "resolved": "9.0.11", - "contentHash": "l5L3Ov+pyD0dfK2bv6IMU2KPEyaaWnix6U0/YhgkNBGEOAgVTVlvh5ZyXWuuRlCtLnOziz+VtM5HFeqLlH2AbA==" + "resolved": "9.0.12", + "contentHash": "T69549unMgkU+kbmDOVWYplDiJP6+b1V4NxXh/ao6ITp9xfWCeNPd/H8OI/WLxM/jjYreAVOLJaNayxtFVd7vA==" } }, "net8.0/win-x64": { @@ -599,8 +606,8 @@ }, "System.Text.Encodings.Web": { "type": "Transitive", - "resolved": "9.0.11", - "contentHash": "l5L3Ov+pyD0dfK2bv6IMU2KPEyaaWnix6U0/YhgkNBGEOAgVTVlvh5ZyXWuuRlCtLnOziz+VtM5HFeqLlH2AbA==" + "resolved": "9.0.12", + "contentHash": "T69549unMgkU+kbmDOVWYplDiJP6+b1V4NxXh/ao6ITp9xfWCeNPd/H8OI/WLxM/jjYreAVOLJaNayxtFVd7vA==" } }, "net9.0": { @@ -622,6 +629,12 @@ "System.Management": "9.0.5" } }, + "Bogus": { + "type": "Direct", + "requested": "[35.5.1, )", + "resolved": "35.5.1", + "contentHash": "GBp2peww04szEJ0GlBlzCYilFDaSkL7Ja4m37YeTRjC/mgoiZnUuifmgUxVD/oLU2MC1uoXfQYK91doGp7Zkpg==" + }, "Ocelot.Testing": { "type": "Direct", "requested": "[24.1.0-beta.1, )", @@ -658,6 +671,12 @@ "StyleCop.Analyzers.Unstable": "1.2.0.556" } }, + "System.Text.Json": { + "type": "Direct", + "requested": "[9.0.12, )", + "resolved": "9.0.12", + "contentHash": "wHv2GrfYd4/uaoZQJj6NOR8M0AlnWJ2/MFAHQomSMqk+/rSIY6AlcitL6LXbTgXf8+ngGjAAmQm17kfbNplQ9w==" + }, "BenchmarkDotNet.Annotations": { "type": "Transitive", "resolved": "0.15.8", @@ -1077,19 +1096,14 @@ "resolved": "5.0.0", "contentHash": "t0MGLukB5WAVU9bO3MGzvlGnyJPgUlcwerXn1kzBRjwLKixT96XV0Uza41W49gVd8zEMFu9vQEFlv0IOrytICA==" }, - "System.Text.Json": { - "type": "Transitive", - "resolved": "9.0.11", - "contentHash": "DGToqSFbBSU6pMSbZuJ+7jDvLa73rvpcYdGFqZIB3FKdCVlEAbrBJrl9PuCT6E0QbdhXjPwqalYc5lxjUqMQzw==" - }, "ocelot": { "type": "Project", "dependencies": { "FluentValidation": "[12.1.1, )", "IPAddressRange": "[6.3.0, )", "Microsoft.AspNetCore.MiddlewareAnalysis": "[9.0.11, )", - "Microsoft.AspNetCore.Mvc.NewtonsoftJson": "[9.0.11, )", - "Microsoft.Extensions.DiagnosticAdapter": "[3.1.32, )" + "Microsoft.Extensions.DiagnosticAdapter": "[3.1.32, )", + "System.Text.Json": "[9.0.12, )" } } }, diff --git a/test/Ocelot.ManualTest/Middlewares/MetadataMiddleware.cs b/test/Ocelot.ManualTest/Middlewares/MetadataMiddleware.cs index 77570d58a..f41b82c18 100644 --- a/test/Ocelot.ManualTest/Middlewares/MetadataMiddleware.cs +++ b/test/Ocelot.ManualTest/Middlewares/MetadataMiddleware.cs @@ -1,4 +1,5 @@ -using Ocelot.Logging; +using Ocelot.Infrastructure; +using Ocelot.Logging; using Ocelot.Middleware; using System.Text.Json; @@ -15,8 +16,8 @@ public static Task Invoke(HttpContext context, Func next) { logger.LogInformation(() => { - var metadataInJson = JsonSerializer.Serialize(metadata, JsonSerializerOptions.Web); - var message = $"{nameof(MetadataMiddleware)} found some metadata: {metadataInJson}"; + var metadataInJson = JsonSerializer.Serialize(metadata, OcelotSerializerOptions.Web); + var message = $"My {nameof(MetadataMiddleware)} found some metadata: {metadataInJson}"; return message; }); } diff --git a/test/Ocelot.ManualTest/packages.lock.json b/test/Ocelot.ManualTest/packages.lock.json index da0b50f30..9e73770be 100644 --- a/test/Ocelot.ManualTest/packages.lock.json +++ b/test/Ocelot.ManualTest/packages.lock.json @@ -465,8 +465,8 @@ }, "System.IO.Pipelines": { "type": "Transitive", - "resolved": "9.0.11", - "contentHash": "NfGnevAV0r2gqtZWxa/7uCm3MNRYz1o4WRHhFahgBq46LuG2eaLwXIlPgtgaRUvf9CCrGFnuzN47MOzJUH1HKg==" + "resolved": "9.0.12", + "contentHash": "LyvCiOzotNkRgn4wtksKjp/KEljoNtQpuAdunh6PipeyRP/qIdzmeeIjFLUaknkk237eMuYYi2YbkG0pbFBpDg==" }, "System.Management": { "type": "Transitive", @@ -483,16 +483,16 @@ }, "System.Text.Encodings.Web": { "type": "Transitive", - "resolved": "9.0.11", - "contentHash": "l5L3Ov+pyD0dfK2bv6IMU2KPEyaaWnix6U0/YhgkNBGEOAgVTVlvh5ZyXWuuRlCtLnOziz+VtM5HFeqLlH2AbA==" + "resolved": "9.0.12", + "contentHash": "T69549unMgkU+kbmDOVWYplDiJP6+b1V4NxXh/ao6ITp9xfWCeNPd/H8OI/WLxM/jjYreAVOLJaNayxtFVd7vA==" }, "System.Text.Json": { "type": "Transitive", - "resolved": "9.0.11", - "contentHash": "DGToqSFbBSU6pMSbZuJ+7jDvLa73rvpcYdGFqZIB3FKdCVlEAbrBJrl9PuCT6E0QbdhXjPwqalYc5lxjUqMQzw==", + "resolved": "9.0.12", + "contentHash": "wHv2GrfYd4/uaoZQJj6NOR8M0AlnWJ2/MFAHQomSMqk+/rSIY6AlcitL6LXbTgXf8+ngGjAAmQm17kfbNplQ9w==", "dependencies": { - "System.IO.Pipelines": "9.0.11", - "System.Text.Encodings.Web": "9.0.11" + "System.IO.Pipelines": "9.0.12", + "System.Text.Encodings.Web": "9.0.12" } }, "ocelot": { @@ -501,8 +501,8 @@ "FluentValidation": "[12.1.1, )", "IPAddressRange": "[6.3.0, )", "Microsoft.AspNetCore.MiddlewareAnalysis": "[8.0.22, )", - "Microsoft.AspNetCore.Mvc.NewtonsoftJson": "[8.0.22, )", - "Microsoft.Extensions.DiagnosticAdapter": "[3.1.32, )" + "Microsoft.Extensions.DiagnosticAdapter": "[3.1.32, )", + "System.Text.Json": "[9.0.12, )" } } }, @@ -522,8 +522,8 @@ }, "System.Text.Encodings.Web": { "type": "Transitive", - "resolved": "9.0.11", - "contentHash": "l5L3Ov+pyD0dfK2bv6IMU2KPEyaaWnix6U0/YhgkNBGEOAgVTVlvh5ZyXWuuRlCtLnOziz+VtM5HFeqLlH2AbA==" + "resolved": "9.0.12", + "contentHash": "T69549unMgkU+kbmDOVWYplDiJP6+b1V4NxXh/ao6ITp9xfWCeNPd/H8OI/WLxM/jjYreAVOLJaNayxtFVd7vA==" } }, "net8.0/win-x64": { @@ -542,8 +542,8 @@ }, "System.Text.Encodings.Web": { "type": "Transitive", - "resolved": "9.0.11", - "contentHash": "l5L3Ov+pyD0dfK2bv6IMU2KPEyaaWnix6U0/YhgkNBGEOAgVTVlvh5ZyXWuuRlCtLnOziz+VtM5HFeqLlH2AbA==" + "resolved": "9.0.12", + "contentHash": "T69549unMgkU+kbmDOVWYplDiJP6+b1V4NxXh/ao6ITp9xfWCeNPd/H8OI/WLxM/jjYreAVOLJaNayxtFVd7vA==" } }, "net9.0": { @@ -1022,8 +1022,8 @@ }, "System.Text.Json": { "type": "Transitive", - "resolved": "9.0.11", - "contentHash": "DGToqSFbBSU6pMSbZuJ+7jDvLa73rvpcYdGFqZIB3FKdCVlEAbrBJrl9PuCT6E0QbdhXjPwqalYc5lxjUqMQzw==" + "resolved": "9.0.12", + "contentHash": "wHv2GrfYd4/uaoZQJj6NOR8M0AlnWJ2/MFAHQomSMqk+/rSIY6AlcitL6LXbTgXf8+ngGjAAmQm17kfbNplQ9w==" }, "ocelot": { "type": "Project", @@ -1031,8 +1031,8 @@ "FluentValidation": "[12.1.1, )", "IPAddressRange": "[6.3.0, )", "Microsoft.AspNetCore.MiddlewareAnalysis": "[9.0.11, )", - "Microsoft.AspNetCore.Mvc.NewtonsoftJson": "[9.0.11, )", - "Microsoft.Extensions.DiagnosticAdapter": "[3.1.32, )" + "Microsoft.Extensions.DiagnosticAdapter": "[3.1.32, )", + "System.Text.Json": "[9.0.12, )" } } }, diff --git a/test/Ocelot.UnitTests/Configuration/DiskFileConfigurationRepositoryTests.cs b/test/Ocelot.UnitTests/Configuration/DiskFileConfigurationRepositoryTests.cs index 8323b9747..bd74ba248 100644 --- a/test/Ocelot.UnitTests/Configuration/DiskFileConfigurationRepositoryTests.cs +++ b/test/Ocelot.UnitTests/Configuration/DiskFileConfigurationRepositoryTests.cs @@ -1,10 +1,11 @@ using Microsoft.AspNetCore.Hosting; -using Newtonsoft.Json; using Ocelot.Configuration.ChangeTracking; using Ocelot.Configuration.File; using Ocelot.Configuration.Repository; -using Ocelot.DependencyInjection; -using System.Runtime.CompilerServices; +using Ocelot.DependencyInjection; +using Ocelot.Infrastructure; +using System.Runtime.CompilerServices; +using System.Text.Json; namespace Ocelot.UnitTests.Configuration; @@ -156,14 +157,14 @@ private void ThenTheConfigurationIsStoredAs(FileConfiguration expecteds) private static void ThenTheOcelotJsonIsStoredAs(FileInfo ocelotJson, FileConfiguration expecteds) { var actual = File.ReadAllText(ocelotJson.FullName); - var expectedText = JsonConvert.SerializeObject(expecteds, Formatting.Indented); + var expectedText = JsonSerializer.Serialize(expecteds, OcelotSerializerOptions.WebWriteIndented); actual.ShouldBe(expectedText); } private void GivenTheConfigurationIs(FileConfiguration fileConfiguration, [CallerMemberName] string environmentName = null) { - var environmentSpecificPath = Path.Combine(TestID, string.Format(ConfigurationBuilderExtensions.EnvironmentConfigFile, environmentName)); - var jsonConfiguration = JsonConvert.SerializeObject(fileConfiguration, Formatting.Indented); + var environmentSpecificPath = Path.Combine(TestID, string.Format(ConfigurationBuilderExtensions.EnvironmentConfigFile, environmentName)); + var jsonConfiguration = JsonSerializer.Serialize(fileConfiguration, OcelotSerializerOptions.WebWriteIndented); var environmentSpecific = new FileInfo(environmentSpecificPath); if (environmentSpecific.Exists) { @@ -178,7 +179,7 @@ private void ThenTheConfigurationJsonIsIndented(FileConfiguration expecteds, [Ca { var environmentSpecific = Path.Combine(TestID, string.Format(ConfigurationBuilderExtensions.EnvironmentConfigFile, environmentName)); var actual = File.ReadAllText(environmentSpecific); - var expectedText = JsonConvert.SerializeObject(expecteds, Formatting.Indented); + var expectedText = JsonSerializer.Serialize(expecteds, OcelotSerializerOptions.WebWriteIndented); actual.ShouldBe(expectedText); files.Add(environmentSpecific); } diff --git a/test/Ocelot.UnitTests/Consul/ConsulFileConfigurationRepositoryTests.cs b/test/Ocelot.UnitTests/Consul/ConsulFileConfigurationRepositoryTests.cs index 474c5c1ac..d10b8cdcf 100644 --- a/test/Ocelot.UnitTests/Consul/ConsulFileConfigurationRepositoryTests.cs +++ b/test/Ocelot.UnitTests/Consul/ConsulFileConfigurationRepositoryTests.cs @@ -1,13 +1,14 @@ using Consul; using Microsoft.Extensions.Options; -using Newtonsoft.Json; using Ocelot.Cache; -using Ocelot.Configuration.File; +using Ocelot.Configuration.File; +using Ocelot.Infrastructure; using Ocelot.Logging; using Ocelot.Provider.Consul; using Ocelot.Provider.Consul.Interfaces; using Ocelot.Responses; -using System.Text; +using System.Text; +using System.Text.Json; namespace Ocelot.UnitTests.Consul; @@ -141,8 +142,8 @@ private void GivenTheConfigKeyComesFromFileConfig(string key) private void ThenTheConfigurationIs(FileConfiguration config) { - var expected = JsonConvert.SerializeObject(config, Formatting.Indented); - var result = JsonConvert.SerializeObject(_getResult.Data, Formatting.Indented); + var expected = JsonSerializer.Serialize(config, OcelotSerializerOptions.WebWriteIndented); + var result = JsonSerializer.Serialize(_getResult.Data, OcelotSerializerOptions.WebWriteIndented); result.ShouldBe(expected); } @@ -169,7 +170,7 @@ private void GivenFetchFromConsulReturnsNull() private void GivenFetchFromConsulSucceeds() { - var json = JsonConvert.SerializeObject(_fileConfiguration, Formatting.Indented); + var json = JsonSerializer.Serialize(_fileConfiguration, OcelotSerializerOptions.WebWriteIndented); var bytes = Encoding.UTF8.GetBytes(json); var kvp = new KVPair("OcelotConfiguration") { @@ -185,7 +186,7 @@ private void GivenFetchFromConsulSucceeds() private void ThenTheConfigurationIsStoredAs(FileConfiguration config) { - var json = JsonConvert.SerializeObject(config, Formatting.Indented); + var json = JsonSerializer.Serialize(config, OcelotSerializerOptions.WebWriteIndented); var bytes = Encoding.UTF8.GetBytes(json); _kvEndpoint.Verify(x => x.Put(It.Is(k => k.Value.SequenceEqual(bytes)), It.IsAny()), Times.Once); } diff --git a/test/Ocelot.UnitTests/Consul/ConsulTests.cs b/test/Ocelot.UnitTests/Consul/ConsulTests.cs index 5b77ab730..15a6ecd0f 100644 --- a/test/Ocelot.UnitTests/Consul/ConsulTests.cs +++ b/test/Ocelot.UnitTests/Consul/ConsulTests.cs @@ -2,11 +2,12 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; -using Newtonsoft.Json; +using Ocelot.Infrastructure; using Ocelot.Logging; using Ocelot.Provider.Consul; using Ocelot.Provider.Consul.Interfaces; using System.Runtime.CompilerServices; +using System.Text.Json; using ConsulProvider = Ocelot.Provider.Consul.Consul; namespace Ocelot.UnitTests.Consul; @@ -206,7 +207,7 @@ private void GivenThereIsAFakeConsulServiceDiscoveryProvider([CallerMemberName] _receivedToken = values.First(); } - var json = JsonConvert.SerializeObject(_consulServiceEntries); + var json = JsonSerializer.Serialize(_consulServiceEntries, OcelotSerializerOptions.Web); context.Response.Headers.Append("Content-Type", "application/json"); await context.Response.WriteAsync(json); } diff --git a/test/Ocelot.UnitTests/DependencyInjection/ConfigurationBuilderExtensionsTests.cs b/test/Ocelot.UnitTests/DependencyInjection/ConfigurationBuilderExtensionsTests.cs index 1e8cea186..5cfaef737 100644 --- a/test/Ocelot.UnitTests/DependencyInjection/ConfigurationBuilderExtensionsTests.cs +++ b/test/Ocelot.UnitTests/DependencyInjection/ConfigurationBuilderExtensionsTests.cs @@ -1,10 +1,11 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.VisualStudio.TestPlatform.ObjectModel; -using Newtonsoft.Json; using Ocelot.Configuration.File; using Ocelot.DependencyInjection; +using Ocelot.Infrastructure; using System.Runtime.CompilerServices; +using System.Text.Json; namespace Ocelot.UnitTests.DependencyInjection; @@ -188,7 +189,7 @@ private void GivenMultipleConfigurationFiles(string folder, bool withEnvironment foreach (var part in configParts) { var filename = Path.Combine(folder, string.Format(ConfigurationBuilderExtensions.EnvironmentConfigFile, part.Key)); - File.WriteAllText(filename, JsonConvert.SerializeObject(part.Value, Formatting.Indented)); + File.WriteAllText(filename, JsonSerializer.Serialize(part.Value, OcelotSerializerOptions.WebWriteIndented)); files.Add(filename); } } diff --git a/test/Ocelot.UnitTests/DependencyInjection/OcelotBuilderTests.cs b/test/Ocelot.UnitTests/DependencyInjection/OcelotBuilderTests.cs index 194bc1af0..a38e001f5 100644 --- a/test/Ocelot.UnitTests/DependencyInjection/OcelotBuilderTests.cs +++ b/test/Ocelot.UnitTests/DependencyInjection/OcelotBuilderTests.cs @@ -7,7 +7,6 @@ using Microsoft.AspNetCore.Mvc.ApplicationParts; using Microsoft.AspNetCore.Mvc.Controllers; using Microsoft.AspNetCore.Mvc.Infrastructure; -using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; @@ -352,17 +351,11 @@ private void CstorShouldUseDefaultBuilderToInitMvcCoreBuilder() .ShouldNotBeNull() .GetType().Name.ShouldBe("AuthorizationApplicationModelProvider"); - // .AddNewtonsoftJson() - _serviceProvider.GetServices>() - .FirstOrDefault(s => s.GetType().Name == "NewtonsoftJsonMvcOptionsSetup") + // use system text json + _serviceProvider.GetServices>() + .FirstOrDefault(s => s.GetType().Name == "SystemTextJsonResultExecutor") .ShouldNotBeNull(); - _serviceProvider.GetService>() - .ShouldNotBeNull() - .GetType().Name.ShouldBe("NewtonsoftJsonResultExecutor"); - _serviceProvider.GetService() - .ShouldNotBeNull() - .GetType().Name.ShouldBe("NewtonsoftJsonHelper"); - } + } [Fact] public void Should_use_custom_mvc_builder_no_configuration() diff --git a/test/Ocelot.UnitTests/Kubernetes/KubeTests.cs b/test/Ocelot.UnitTests/Kubernetes/KubeTests.cs index 768adbceb..6edadf0fa 100644 --- a/test/Ocelot.UnitTests/Kubernetes/KubeTests.cs +++ b/test/Ocelot.UnitTests/Kubernetes/KubeTests.cs @@ -3,12 +3,13 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; -using Newtonsoft.Json; +using Ocelot.Infrastructure; using Ocelot.Logging; using Ocelot.Provider.Kubernetes; using Ocelot.Provider.Kubernetes.Interfaces; using Ocelot.Values; using System.Runtime.CompilerServices; +using System.Text.Json; namespace Ocelot.UnitTests.Kubernetes; @@ -19,8 +20,7 @@ namespace Ocelot.UnitTests.Kubernetes; [Collection(nameof(SequentialTests))] public class KubeTests : FileUnitTest { - static JsonSerializerSettings JsonSerializerSettings => KubeClient.ResourceClients.KubeResourceClient.SerializerSettings; - + // static JsonSerializerSettings JsonSerializerSettings => KubeClient.ResourceClients.KubeResourceClient.SerializerSettings; private readonly Mock _factory; private readonly Mock _logger; @@ -233,17 +233,17 @@ Task ProcessKubernetesRequest(HttpContext context) if (responseStatusCode == HttpStatusCode.OK) { - responseBody = JsonConvert.SerializeObject(endpointEntries, JsonSerializerSettings); + responseBody = JsonSerializer.Serialize(endpointEntries, OcelotSerializerOptions.Web); } else { - responseBody = JsonConvert.SerializeObject(new StatusV1 + responseBody = JsonSerializer.Serialize(new StatusV1 { Message = GetKubeApiErrorMessage(serviceName, namespaces, responseStatusCode), Reason = responseStatusCode.ToString(), Code = (int)responseStatusCode, Status = StatusV1.FailureStatus, - }, JsonSerializerSettings); + }, OcelotSerializerOptions.Web); // JsonSerializerSettings); } context.Response.StatusCode = (int)responseStatusCode; diff --git a/test/Ocelot.UnitTests/OcelotSerializerOptionsTests.cs b/test/Ocelot.UnitTests/OcelotSerializerOptionsTests.cs new file mode 100644 index 000000000..a488393bc --- /dev/null +++ b/test/Ocelot.UnitTests/OcelotSerializerOptionsTests.cs @@ -0,0 +1,70 @@ +using Ocelot.Infrastructure; +using System.Text.Json; + +namespace Ocelot.UnitTests; + +public class OcelotSerializerOptionsTests : UnitTest +{ + [Fact] + public void should_json_path() + { + //Arrange + var json = "{\"id\":1,\"writerId\":1,\"postId\":2,\"text\":\"text1\"}"; + var path = "$writerId"; + var document = JsonDocument.Parse(json); + + //Act + var result = document.ExtractValuesFromJsonPath(path); + + //Assert + result.ShouldBeEquivalentTo(new List { "1" }); + } + + [Fact] + public void should_json_path_array() + { + //Arrange + var json = + "[{\"id\":1,\"writerId\":1,\"postId\":2,\"text\":\"text1\"},{\"id\":2,\"writerId\":1,\"postId\":2,\"text\":\"text2\"}]"; + var path = "$[*].writerId"; + var document = JsonDocument.Parse(json); + + //Act + var result = document.ExtractValuesFromJsonPath(path); + + //Assert + result.ShouldBeEquivalentTo(new List { "1", "1" }); + } + + [Fact] + public void should_json_path_nested() + { + //Arrange + var json = + "[{\"id\":1,\"writerId\":1,\"postId\":2,\"text\":\"text1\",\"comments\":[{\"commentId\":1,\"text\":\"Good post!\"},{\"commentId\":2,\"text\":\"Nice post!\"}]},{\"id\":2,\"writerId\":2,\"postId\":2,\"text\":\"text2\",\"comments\":[{\"commentId\":3,\"text\":\"Interesting.\"}]}]"; + var path = "$[*].comments[*].text"; + var document = JsonDocument.Parse(json); + + //Act + var result = document.ExtractValuesFromJsonPath(path); + + //Assert + result.ShouldBeEquivalentTo(new List { "Good post!", "Nice post!", "Interesting." }); + } + + [Fact] + public void should_json_path_nested_null() + { + //Arrange + var json = + "[{\"id\":1,\"writerId\":1,\"postId\":2,\"text\":\"text1\",\"comments\":[{\"commentId\":1,\"text\":null},{\"commentId\":2,\"text\":\"Nice post!\"}]},{\"id\":2,\"writerId\":2,\"postId\":2,\"text\":\"text2\",\"comments\":[{\"commentId\":3,\"text\":\"Interesting.\"}]}]"; + var path = "$[*].comments[*].text"; + var document = JsonDocument.Parse(json); + + //Act + var result = document.ExtractValuesFromJsonPath(path); + + //Assert + result.ShouldBeEquivalentTo(new List { "Nice post!", "Interesting." }); + } +} diff --git a/test/Ocelot.UnitTests/RateLimiting/DistributedCacheRateLimitStorageTests.cs b/test/Ocelot.UnitTests/RateLimiting/DistributedCacheRateLimitStorageTests.cs index 52bbcc3d3..ff000d12f 100644 --- a/test/Ocelot.UnitTests/RateLimiting/DistributedCacheRateLimitStorageTests.cs +++ b/test/Ocelot.UnitTests/RateLimiting/DistributedCacheRateLimitStorageTests.cs @@ -1,7 +1,7 @@ using Microsoft.Extensions.Caching.Distributed; -using Newtonsoft.Json; using Ocelot.RateLimiting; using System.Text; +using System.Text.Json; namespace Ocelot.UnitTests.RateLimiting; @@ -23,7 +23,7 @@ public void Set_ShouldSerializeAndStoreValue() var id = "test-id"; var counter = new RateLimitCounter(DateTime.UtcNow, null, 5); var expiration = TimeSpan.FromMinutes(1); - var expectedJson = JsonConvert.SerializeObject(counter); + var expectedJson = JsonSerializer.Serialize(counter); var expectedBytes = Encoding.UTF8.GetBytes(expectedJson); _cache.Setup(c => c.Set(id, It.IsAny(), It.IsAny())); @@ -59,7 +59,7 @@ public void Get_ShouldDeserializeStoredValue() // Arrange var id = "get-id"; var counter = new RateLimitCounter(DateTime.UtcNow, null, 3); - var json = JsonConvert.SerializeObject(counter); + var json = JsonSerializer.Serialize(counter); var bytes = Encoding.UTF8.GetBytes(json); _cache.Setup(c => c.Get(id)).Returns(bytes); diff --git a/test/Ocelot.UnitTests/RateLimiting/RateLimitingTests.cs b/test/Ocelot.UnitTests/RateLimiting/RateLimitingTests.cs index 4c775b74e..65e6ea3ff 100644 --- a/test/Ocelot.UnitTests/RateLimiting/RateLimitingTests.cs +++ b/test/Ocelot.UnitTests/RateLimiting/RateLimitingTests.cs @@ -231,7 +231,7 @@ public void RetryAfter_DoNotWait_RetryAfterTheHalfOfPeriod(string doNotWait) RateLimitCounter counter = new( startedAt: now.AddSeconds(-rule.PeriodSpan.TotalSeconds / 2), exceededAt: now, - totalRequests: total); + total: total); // Act double actual = _sut.RetryAfter(counter, rule, now); @@ -251,7 +251,7 @@ public void RetryAfter_ExceedingInWaitingWindow_RetryAfterTheQuarterOfWaitPeriod RateLimitCounter counter = new( startedAt: now.AddSeconds(-(rule.PeriodSpan.TotalSeconds / 2) - (rule.WaitSpan.TotalSeconds / 4 * 3)), exceededAt: now.AddSeconds(-(rule.WaitSpan.TotalSeconds / 4 * 3)), - totalRequests: total); + total: total); // Act double actual = _sut.RetryAfter(counter, rule, now); @@ -271,7 +271,7 @@ public void RetryAfter_Exceeding_WaitingPeriodElapsed_NoNeedToRetry() RateLimitCounter counter = new( startedAt: now.AddSeconds(-rule.PeriodSpan.TotalSeconds - rule.WaitSpan.TotalSeconds), exceededAt: now.AddSeconds(-rule.WaitSpan.TotalSeconds), - totalRequests: total); + total: total); // Act double actual = _sut.RetryAfter(counter, rule, now); diff --git a/test/Ocelot.UnitTests/packages.lock.json b/test/Ocelot.UnitTests/packages.lock.json index e3aa9b525..2992af7c2 100644 --- a/test/Ocelot.UnitTests/packages.lock.json +++ b/test/Ocelot.UnitTests/packages.lock.json @@ -1525,8 +1525,8 @@ }, "System.IO.Pipelines": { "type": "Transitive", - "resolved": "9.0.11", - "contentHash": "NfGnevAV0r2gqtZWxa/7uCm3MNRYz1o4WRHhFahgBq46LuG2eaLwXIlPgtgaRUvf9CCrGFnuzN47MOzJUH1HKg==" + "resolved": "9.0.12", + "contentHash": "LyvCiOzotNkRgn4wtksKjp/KEljoNtQpuAdunh6PipeyRP/qIdzmeeIjFLUaknkk237eMuYYi2YbkG0pbFBpDg==" }, "System.Linq": { "type": "Transitive", @@ -2016,16 +2016,16 @@ }, "System.Text.Encodings.Web": { "type": "Transitive", - "resolved": "9.0.11", - "contentHash": "l5L3Ov+pyD0dfK2bv6IMU2KPEyaaWnix6U0/YhgkNBGEOAgVTVlvh5ZyXWuuRlCtLnOziz+VtM5HFeqLlH2AbA==" + "resolved": "9.0.12", + "contentHash": "T69549unMgkU+kbmDOVWYplDiJP6+b1V4NxXh/ao6ITp9xfWCeNPd/H8OI/WLxM/jjYreAVOLJaNayxtFVd7vA==" }, "System.Text.Json": { "type": "Transitive", - "resolved": "9.0.11", - "contentHash": "DGToqSFbBSU6pMSbZuJ+7jDvLa73rvpcYdGFqZIB3FKdCVlEAbrBJrl9PuCT6E0QbdhXjPwqalYc5lxjUqMQzw==", + "resolved": "9.0.12", + "contentHash": "wHv2GrfYd4/uaoZQJj6NOR8M0AlnWJ2/MFAHQomSMqk+/rSIY6AlcitL6LXbTgXf8+ngGjAAmQm17kfbNplQ9w==", "dependencies": { - "System.IO.Pipelines": "9.0.11", - "System.Text.Encodings.Web": "9.0.11" + "System.IO.Pipelines": "9.0.12", + "System.Text.Encodings.Web": "9.0.12" } }, "System.Text.RegularExpressions": { @@ -2207,8 +2207,8 @@ "FluentValidation": "[12.1.1, )", "IPAddressRange": "[6.3.0, )", "Microsoft.AspNetCore.MiddlewareAnalysis": "[8.0.22, )", - "Microsoft.AspNetCore.Mvc.NewtonsoftJson": "[8.0.22, )", - "Microsoft.Extensions.DiagnosticAdapter": "[3.1.32, )" + "Microsoft.Extensions.DiagnosticAdapter": "[3.1.32, )", + "System.Text.Json": "[9.0.12, )" } }, "ocelot.cache.cachemanager": { @@ -3168,8 +3168,8 @@ }, "System.Text.Encodings.Web": { "type": "Transitive", - "resolved": "9.0.11", - "contentHash": "l5L3Ov+pyD0dfK2bv6IMU2KPEyaaWnix6U0/YhgkNBGEOAgVTVlvh5ZyXWuuRlCtLnOziz+VtM5HFeqLlH2AbA==" + "resolved": "9.0.12", + "contentHash": "T69549unMgkU+kbmDOVWYplDiJP6+b1V4NxXh/ao6ITp9xfWCeNPd/H8OI/WLxM/jjYreAVOLJaNayxtFVd7vA==" }, "System.Threading.Tasks": { "type": "Transitive", @@ -4090,8 +4090,8 @@ }, "System.Text.Encodings.Web": { "type": "Transitive", - "resolved": "9.0.11", - "contentHash": "l5L3Ov+pyD0dfK2bv6IMU2KPEyaaWnix6U0/YhgkNBGEOAgVTVlvh5ZyXWuuRlCtLnOziz+VtM5HFeqLlH2AbA==" + "resolved": "9.0.12", + "contentHash": "T69549unMgkU+kbmDOVWYplDiJP6+b1V4NxXh/ao6ITp9xfWCeNPd/H8OI/WLxM/jjYreAVOLJaNayxtFVd7vA==" }, "System.Threading.Overlapped": { "type": "Transitive", @@ -6143,8 +6143,8 @@ }, "System.Text.Json": { "type": "Transitive", - "resolved": "9.0.11", - "contentHash": "DGToqSFbBSU6pMSbZuJ+7jDvLa73rvpcYdGFqZIB3FKdCVlEAbrBJrl9PuCT6E0QbdhXjPwqalYc5lxjUqMQzw==" + "resolved": "9.0.12", + "contentHash": "wHv2GrfYd4/uaoZQJj6NOR8M0AlnWJ2/MFAHQomSMqk+/rSIY6AlcitL6LXbTgXf8+ngGjAAmQm17kfbNplQ9w==" }, "System.Text.RegularExpressions": { "type": "Transitive", @@ -6325,8 +6325,8 @@ "FluentValidation": "[12.1.1, )", "IPAddressRange": "[6.3.0, )", "Microsoft.AspNetCore.MiddlewareAnalysis": "[9.0.11, )", - "Microsoft.AspNetCore.Mvc.NewtonsoftJson": "[9.0.11, )", - "Microsoft.Extensions.DiagnosticAdapter": "[3.1.32, )" + "Microsoft.Extensions.DiagnosticAdapter": "[3.1.32, )", + "System.Text.Json": "[9.0.12, )" } }, "ocelot.cache.cachemanager": {