eterm
Most efficient way to modify json in C#
I don't fully understand your use-case, but shouldn't you know the key for any data you're accessing? Storing keys inside the value in a KV store always makes me feel like something isn't quite right. It just provides an opportunity for the "inner" and "outer" keys to get out of sync, especially if you have to jump through this kind of hoop to set it.
Rather than trying to recreate the online store offline, I'd take a step back and try to work out what data you're trying to preserve, and create your offline storage and serialisation against that requirement, rather than trying to serialize and store an already serialized format.
I'd also note that if you are allowing start-up-offline, then you'll also need to have a strategy for re-synchronising changes when getting back online, which can be a harder problem to tackle.
44 replies
Most efficient way to modify json in C#
Hi, welcome. I have a few points / questions:
1. Is this a noticeable performance issue / bottleneck? i.e. Does it need to be "efficient"?
2. You might find it more efficient to go direct via the database in some circumstances. SQL Server supports
json_modify
T-SQL commands, for instance.
3. Is that NewtonSoft.Json
rather than System.Text.Json
? You could compare the performance of this approach to JsonNode
in System.Text.Json
( https://learn.microsoft.com/en-us/dotnet/standard/serialization/system-text-json/use-dom ).44 replies