Tuesday, October 29, 2019

NewtonSoft Json Test pad

Nearly for the last 10 months half the time in my day job, I am working with Microsoft on optimizing the performance of our flagship application. Not really my current company's application but for the client which is one of the big 4 auditing firms. Sorry, as per NDA, I am not allowed to reveal the client name:)

It is a legacy application someone started in what we now call classic VB when I was in high school. It then converted to .Net then to WPF, then made SOA finally in AngularJS 1.X. I don't think its really converted but people started calling it in different technology. Nothing in WPF blocks you writing code in the WinForms way. It's really a legacy giant with 100s of .vbproj & .csproj files.

One of the problems we discovered was the JSON serialization. Though developers wanted to use NewtonSoft.JSON, they were using JavaScript serializer as that is the built-in JSON serializer in .Net. For using built in things, they don't need additional permissions. At some point, Microsoft figured out from the performance tuning data (perfview.exe) that the JavaScriptSerializer is slow than the NewtonSoft.JSON serializer. Though we all knew the fact, we never expected Microsoft telling that it is the bottleneck in the system and needs to be fixed.

It is declared that the NewtonSoft.JSON serializer would be the defacto serializer going forward. Developers started changing JavaScriptSerializer to NewsonSoft. 

One of the tools which came to demand is a test pad for NewtonSoft.JSON. Given a JSON string, how to easily develop the query to find something in JSON via NewtonSoft.JSON. We can easily use Linq but some are easy with the SelectToken(). We started searching for an online NewtonSoft test pad something similar to JSFiddle. Or some desktop tools similar to LINQPad.

After a good amount of googling ended up using https://dotnetfiddle.net. That has support to add nuget packages. Even we didn't have to start from scratch. Fork the below snippet to start with. 

https://dotnetfiddle.net/QQbpk5

Happy coding...

No comments: