Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
d8c606f
feat: rm newtonsoft
EngRajabi Jul 15, 2024
635439b
feat: add system text json config
EngRajabi Jul 19, 2024
4d14ebb
fix: AcceptanceTest ConsulServiceDiscovery
MohammadAminPourmoradian Jul 19, 2024
646b81c
fix: fix indent
EngRajabi Jul 19, 2024
fe5b2fd
feat: change un use
EngRajabi Jul 19, 2024
d5c23c0
feat: add json benchmark
EngRajabi Jul 19, 2024
c7a641c
feat: add json serialize result json
EngRajabi Jul 19, 2024
61247cc
fix
EngRajabi Jul 19, 2024
0048df8
update doc
EngRajabi Jul 19, 2024
c30672f
Revert file MessageInvokerPoolTests.cs
raman-m Jul 22, 2024
6215382
Revert file ocelot.json
raman-m Jul 22, 2024
dfbc87f
Revert file Steps.cs
raman-m Jul 22, 2024
12f1b21
Apply changes in file Steps.cs
raman-m Jul 22, 2024
8667047
Revert file MessageInvokerPool.cs
raman-m Jul 22, 2024
ac74d64
Code review by @raman-m
raman-m Jul 22, 2024
c6897c9
fix: rename and format JsonSerializerOptions class
MohammadAminPourmoradian Jul 28, 2024
147271c
fix: remove unused JsonDocument object
MohammadAminPourmoradian Jul 28, 2024
b65a6d6
add
EngRajabi Oct 3, 2024
0fda6af
fix: rm JsonPath.Net
EngRajabi Oct 3, 2024
4863b2e
fix: add more test
EngRajabi Oct 4, 2024
dea5e37
Fix errors and warnings
raman-m Nov 2, 2024
885ee5b
Fix Ocelot.Benchmarks build
raman-m Nov 2, 2024
bd2da05
fix: fix something
EngRajabi Dec 18, 2024
6b67250
Fix build errors, warnings, messages after rebasing
raman-m Dec 20, 2024
f59ca5e
fix: rm newstonsoft
EngRajabi Dec 21, 2024
2a213d2
fix: rename JsonSerializerOptionsFactory to OcelotSerializerOptions
EngRajabi Dec 21, 2024
d1a464e
Merge 'ThreeMammals:develop' into 'EngRajabi:feat_rm_newtonsoft'
raman-m Jan 16, 2026
df7350d
using Newtonsoft.Json;
raman-m Jan 16, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions docs/features/dependencyinjection.rst
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,14 @@ Current `implementation <https://github.com/search?q=repo%3AThreeMammals%2FOcelo
.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);
});
}

The method cannot be overridden. It is not virtual, and there is no way to override the current behavior by inheritance.
Expand Down
116 changes: 38 additions & 78 deletions src/Ocelot.Cache.CacheManager/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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, )"
}
}
},
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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, )"
}
}
},
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -53,14 +54,14 @@ public async Task<Response<FileConfiguration>> Get()

var bytes = queryResult.Response.Value;
var json = Encoding.UTF8.GetString(bytes);
var consulConfig = JsonConvert.DeserializeObject<FileConfiguration>(json);
var consulConfig = JsonSerializer.Deserialize<FileConfiguration>(json, OcelotSerializerOptions.Web);

return new OkResponse<FileConfiguration>(consulConfig);
}

public async Task<Response> 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)
{
Expand Down
Loading
Loading